Skip to content

Instantly share code, notes, and snippets.

@netoisc
Created July 28, 2017 18:31
Show Gist options
  • Select an option

  • Save netoisc/9147cf12198e66fcd274419e145dd0d4 to your computer and use it in GitHub Desktop.

Select an option

Save netoisc/9147cf12198e66fcd274419e145dd0d4 to your computer and use it in GitHub Desktop.
How to create a startup script to run python script within virtualenv
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