supervisorctl always reports error: ERROR (no such file)

xyxc picture xyxc · Feb 24, 2017 · Viewed 15.1k times · Source

I deploy my django project with uwsgi、supervisor and nginx. but I have added my program like above in the /etc/supervisord.conf.

[program:JZAssist]
command=-E uwsgi --ini /home/work/xxxx/uwsgi.ini
directory=/home/work/xxxx
startsecs=0
stopwaitsecs=0
autostart=true
autorestart=true

and my uwsgi.ini content is:

[uwsgi] 
socket = :8000 
chdir = /home/work/xxxx 
module = xxxx.wsgi 
master = true 
processes = 4 
vacuum = true 

xxxx is my project name.

I run supervisorctl -c /etc/supervisord.conf restart all in the cmd. And it shows

xxxx: ERROR (no such file)

/tmp/supervisord.log part of content:

2017-02-24 23:31:41,433 INFO gave up: JZAssist entered FATAL state,         too many start retries too quickly
2017-02-24 23:52:29,940 WARN Failed to clean up '/tmp/JZAssist-stderr---supervisor-goPZyS.log'
2017-02-24 23:52:29,940 WARN Failed to clean up '/tmp/JZAssist-stdout---supervisor-WtfJcp.log'
2017-02-24 23:52:57,535 WARN Failed to clean up '/tmp/JZAssist-stderr---supervisor-goPZyS.log'
2017-02-24 23:52:57,535 WARN Failed to clean up '/tmp/JZAssist-stdout---supervisor-WtfJcp.log'
2017-02-24 23:52:57,541 INFO RPC interface 'supervisor' initialized
2017-02-24 23:52:57,541 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2017-02-24 23:52:57,542 INFO daemonizing the supervisord process
2017-02-24 23:52:57,543 CRIT could not write pidfile /tmp/supervisord.pid
2017-02-24 23:52:58,544 INFO spawnerr: can't find command '-E'
2017-02-24 23:52:59,546 INFO spawnerr: can't find command '-E'
2017-02-25 00:46:59,234 WARN Failed to clean up '/tmp/JZAssist-stderr---supervisor-goPZyS.log'
2017-02-25 00:46:59,234 WARN Failed to clean up '/tmp/JZAssist-stdout---supervisor-WtfJcp.log'

I don't know why it will report error like that.I can run my django project with runserver.so what the file is missing?

Answer

Daniel Fackrell picture Daniel Fackrell · Aug 17, 2017

On your command= line, you've specified the program to run as -E, which supervisor can't find to execute.

When creating a file for the job, the command line should be executable as a shell command, and should not rely on internal commands for a given shell. For example, I had trouble with one that started with:

source /path/to/python/virtual/environment/bin/activate && ...

but source is a bash builtin. I needed to change it to read:

bash -c 'source /path/to/python/virtual/environment/bin/activate && ...

This way, the executable file that supervisor can find and run is bash.

In your case, it appears uwsgi should be the first thing after command=.

You mentioned that you're using the -E flag to preserve environment variables when you run sudo, but supervisor won't need sudo