Created
July 28, 2017 18:31
-
-
Save netoisc/9147cf12198e66fcd274419e145dd0d4 to your computer and use it in GitHub Desktop.
How to create a startup script to run python script within virtualenv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| description "Start the sos server as service" | |
| start on runlevel [2345] | |
| stop on runlevel [!2345] | |
| respawn | |
| setuid ubuntu | |
| # try 2 times every 10 seconds then stop it if the exec fail | |
| respawn limit 2 10 | |
| # the next env var is very important to avoid decoding errors | |
| env LANG=en_US.UTF-8 | |
| script | |
| cd /home/ubuntu/servers | |
| . env/bin/activate | |
| exec my_python_script.py | |
| end script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment