Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a Python service on ubuntu using upstart

I want to create to deploy a heartbeat service (a python script) as a service using Upstart.

My understanding is that I've to add a /etc/init/myheartbeatservice.conf with the following contents.

# my heartbeat service 

description     "Heartbeat monitor"

start on startup
stop on shutdown

script
    exec /path/to/my/python/script.py
end script 

My script starts another service process and the monitors the processes and sends heartbeat to an outside server regularly. Are startup and shutdown the correct events ? Also my script create a new thread. I'm assuming I also need to add fork daemon to my conf file?

Thanks.

like image 353
Soumya Simanta Avatar asked Mar 05 '26 06:03

Soumya Simanta


1 Answers

Upstart only sets a handful of environment variables. Does your application need any of these set?

See this answer to a similar question: Need help running Python app as service in Ubuntu with Upstart

like image 170
Thomas Bratt Avatar answered Mar 08 '26 07:03

Thomas Bratt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!