Search code examples
pythontornadosupervisord

Python tornado supervisor setup


I am trying to setup my tornado application with Supervisor

Following is my configurations written in supervisor:

[unix_http_server]
file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0700                       ; sockef file mode (default 0700)
chown=nobody:nogroup

[include]
files = /etc/supervisor/*.ini

Rest of the file is same as for the default.

tornado.ini file:

[program:tornado_main]
command=/home/ubuntu/env/bin/python /home/ubuntu/<repo>/__main__.py
directory=/home/ubuntu/<repo>
user=ubuntu
stdout_logfile = /var/log/supervisor/tornado_main.log
stderr_logfile = /var/log/supervisor/tornado_main_err.log

Then I run, sudo service supervisor restart all This runs my tornado app

Now, when I am trying to run one of my APIs (say, http://35.154.145.226:3000/questions/) it's not returning anything

It's giving me an error:

This site can’t be reached

35.154.145.226 took too long to respond.
Search Google for 154 145 226 3000
ERR_CONNECTION_TIMED_OUT

or "could not reach site"

No logs are also added in my log files. Somehow, the IP is not reachable, I guess.

Part of the code in main.py is:

class Application(tornado.web.Application):
    def __init__(self):
        settings = dict(
            static_path=os.path.join(os.path.dirname(__file__), "static"),
            autoescape=None
        )
        tornado.web.Application.__init__(self, urls, **settings)
app = Application()
options.log_file_prefix = "tornado_log"
enable_pretty_logging(options=options)
app.listen(int(config.get('tornado', 'listening_port')))
tornado.autoreload.start()
tornado.ioloop.IOLoop.current().start()

What am I missing here?


Solution

  • ERR_CONNECTION_TIMED_OUT

    One Reason is :

    EC2 (OR whichever you are using) security group has not allowed inbound connection for port no 3000