0
votes

I am trying to create a upstart script for my flask application. I am using uWSGI to run it. My application resides in /home/user/apps/myapp. It contains virtual environment in venv. My goal is to activate the virtual environment and exect ini script there

#description "Starts my app" 
#author "Me <myself@gmail.com>"

start on runlevel [2345]
stop on runlevel [!2345]



script
        cd /home/user/apps/myapp
        source venv/bin/activate
        exec uwsgi --ini myapp.ini
end script

When i run the command sudo start myapp in /etc/init/. I got errors like process terminated with status 127. This means that my command is unkownn. I am new to upstart scripts. What am i doing wrong, these scripts work fine in shell.

1

1 Answers

0
votes

The source command is not a standard shell command. Whatever Upstart is using internally doesn't use it. Use the dot operator instead: . file.

However, you don't need either of the commands before uwsgi, the working directory and virtualenv are both configurable in uWSGI. It is better to let uWSGI handle the virtualenv, source activate is only meant as a convenience during development.

myapp.ini:

[uwsgi]
virtualenv = /path/to/env
chdir = /path/to/project
# other config here