Question

Having some issues getting supervisor to run my tornado apps.

I have a REST API built with Flask, using Tornado to try and serve it. Problem I am having is that when I try to run with supervisor it appears to be failing on import of other supporting python packages.

inf_api is the flask API.

Here is the script for the tornado

from influence_api import app
from tornado.wsgi import WSGIContainer
from tornado.httpserver import HTTPServer
from tornado.ioloop import IOLoop
from tornado.options import define, options

define("port", default=8080, help="Port to listen on", type=int)

if __name__ == '__main__':
    options.parse_command_line()
    http_server = HTTPServer(WSGIContainer(app))
    http_server.listen(options.port)
    IOLoop.instance().start()

Program section of the supervisord.conf (which I have tried several iterations of)

[program:tornado-8080]
autostart=true
autorestart=true
environment=USER=root,PYTHONPATH=/usr/bin/
command=python /media/sf_Projects/inf_api/inf_api/inf_server_nginx.py
stderr_logfile = /var/log/supervisord/tornado-stderr.log
stdout_logfile = /var/log/supervisord/tornado-stdout.log

Ive tried playing around with how much is put in the environment and how much is put directly in the command. Including variations like.....

user=root
autostart=true
autorestart=true
exitcodes=0,1,2
command=env PATH="/usr/bin/python" /media/sf_Projects/inf_api/inf_api/inf_server_nginx.py --port=8081
command=/usr/bin/python /media/sf_Projects/inf_api/inf_api/inf_nginx.py --port=8081
stderr_logfile = /var/log/supervisord/tornado-stderr.log
stdout_logfile = /var/log/supervisord/tornado-stdout.log

Error output from supervisor

2014-02-25 16:55:24,917 INFO spawned: 'tornado-8080' with pid 3527
2014-02-25 16:55:25,156 DEBG 'tornado-8080' stderr output:
Traceback (most recent call last):
  File "/media/sf_Projects/inf_api/inf_api/inf_server_nginx.py", line 11, in <module>

2014-02-25 16:55:25,157 DEBG 'tornado-8080' stderr output:
    from inf_api import app

2014-02-25 16:55:25,157 DEBG 'tornado-8080' stderr output:
  File "/media/sf_Projects/inf_api/inf_api/inf_api.py", line 159, in <module>

2014-02-25 16:55:25,158 DEBG 'tornado-8080' stderr output:
    mongo_ip = read_config('Database')['mongoip']

2014-02-25 16:55:25,158 DEBG 'tornado-8080' stderr output:
  File "/media/sf_Projects/inf_api/inf_api/inf_api.py", line 114, in read_config

2014-02-25 16:55:25,158 DEBG 'tornado-8080' stderr output:
    options = config.options(section)

2014-02-25 16:55:25,159 DEBG 'tornado-8080' stderr output:
  File "/usr/lib/python2.7/ConfigParser.py", line 279, in options
    raise NoSectionError(section)
ConfigParser.NoSectionError: No section: 'Database'
.........
2014-02-25 20:29:26,924 INFO exited: tornado-8080 (exit status 1; not expected)

Running Tornado as is with or without SSL works just fine, as does the Flask API stand alone. Ran supervisord with sudo and without....

As you can see I'm stumped - Any ideas?

Was it helpful?

Solution 2

Think I sorted it out. Made sure all python files in the directory that I was using were executable

chmod +x <FILES>

Modified the Program portion of the supervisord file to look as follows

[program:inf_svr]
process_name=inf_svr%(process_num)s
directory=/media/sf_Projects/inf_api/inf_api/
environment=USER=root,PYTHONPATH=/usr/bin/
command=python /media/sf_Projects/inf_api/inf_api/inf_server_nginx.py
startsecs=2
user=root
autostart=true
autorestart=true
numprocs=1
numprocs_start=8080
stderr_logfile = /var/log/supervisord/tornado-stderr.log
stdout_logfile = /var/log/supervisord/tornado-stdout.log

tornado app starts with no errors and serves the api. On to nginx.....

OTHER TIPS

You are probably looking at the wrong directory for the config file.

Set the directory to run supervisord.

directory=/media/sf_Projects/inf_api/

I'm not sure if this is the directory you want, but this is the way to go.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top