0

Here is how I configure supervisor:

[supervisord]
nodaemon=true

[program:djangoonlyfonts]
command = /code/deploy/gunicorn.sh ; Command to start app
stdout_logfile = /var/log/supervisor/supervisor.log ; Where to write log messages
redirect_stderr = true ; Save stderr in the same log
autostart=true
autorestart=true

gunicorn.sh:

 #!/bin/bash

cd /code
export DJANGO_SETTINGS_MODULE=fuentes.settingsser
/usr/local/bin/gunicorn -b 0.0.0.0:8000 --workers=1 fuentes.wsgi:application

I get:

root@3eb7d4cb7a4e:/code# supervisord
/usr/local/lib/python2.7/site-packages/supervisor/options.py:296: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
  'Supervisord is running as root and it is searching '
2016-08-16 07:53:37,712 CRIT Supervisor running as root (no user in config file)
2016-08-16 07:53:37,715 INFO supervisord started with pid 64
2016-08-16 07:53:38,717 INFO spawned: 'djangoonlyfonts' with pid 67
2016-08-16 07:53:38,721 INFO exited: djangoonlyfonts (exit status 127; not expected)
2016-08-16 07:53:39,723 INFO spawned: 'djangoonlyfonts' with pid 68
2016-08-16 07:53:39,728 INFO exited: djangoonlyfonts (exit status 127; not expected)
2016-08-16 07:53:41,732 INFO spawned: 'djangoonlyfonts' with pid 69
2016-08-16 07:53:41,735 INFO exited: djangoonlyfonts (exit status 127; not expected)
2016-08-16 07:53:44,740 INFO spawned: 'djangoonlyfonts' with pid 70
2016-08-16 07:53:44,743 INFO exited: djangoonlyfonts (exit status 127; not expected)
2016-08-16 07:53:45,745 INFO gave up: djangoonlyfonts entered FATAL state, too many start retries too quickly

but when I execute the command directly:

root@3eb7d4cb7a4e:~# /code/deploy/gunicorn.sh  
[2016-08-16 07:55:19 +0000] [84] [INFO] Starting gunicorn 19.6.0
[2016-08-16 07:55:19 +0000] [84] [INFO] Listening at: http://0.0.0.0:8000 (84)
[2016-08-16 07:55:19 +0000] [84] [INFO] Using worker: sync
[2016-08-16 07:55:19 +0000] [89] [INFO] Booting worker with pid: 89
The production file is loaded

It just works, which proves the file is a perfectly executable and it actually works.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Martin Volpe
  • 91
  • 1
  • 9
  • Can you post your Dockerfile? Or a simpler Dockerfile which demonstrates the same error? The 127 exit status mean [command not found](http://stackoverflow.com/questions/28620656/supervisord-always-returns-exit-status-127-at-webfaction) but it's hard to say why you are getting that error without more info. – joelnb Aug 16 '16 at 12:38
  • I use Docker-Compose to get the code inside the container, it doesn't have much more than that and the file I am trying to execute actually exist because if I execute it directly the server goes up as expected. – Martin Volpe Aug 16 '16 at 17:41
  • Have you got a `volume:` part in your docker-compose.yml for this container? Presumably the case where you are running interactively is not using docker-compose so could be running slightly differently – joelnb Aug 16 '16 at 17:44
  • You are using bash as the shebang, does your docker-image provide bash? e.g. if it is alpine, it does not. In general, 127 means command not found, so it is either not executable ( +x ), cannot be found ( path seems ok ) or the shebang is wrong ( probably your case ). Please also remove all the spaces in the configuration `command=/your/command` - a lot of tools are very picky about this. If this all does not help, try `bash -c -l "/code/deploy/gunicorn.sh"` as a command - does this help? – Eugen Mayer Aug 16 '16 at 21:47
  • Removing spaces I get `2016-08-18 00:07:08,768 INFO spawnerr: can't find command '/code/deploy/gunicorn.sh;'` but with `bash -c -l "/code/deploy/gunicorn.sh` it did work! Is this supposed to be a bug? – Martin Volpe Aug 18 '16 at 02:25

0 Answers0