Note that there are some explanatory texts on larger screens.

plurals
  1. POSupervisor doesn't kill flask application
    primarykey
    data
    text
    <p>I have the following conf file for supervisord:</p> <pre><code>[program:backend] command=../../../venv/bin/python backend.py [program:celeryd] command=../../../venv/bin/celery worker --app=tasks -l debug [program:memcached] command=memcached </code></pre> <p>my backend.py is a pretty standard flask app with debug=True. It's not daemonized (running python backend.py in the console doesn't return the prompt)</p> <p>when I execute <code>supervisord</code>, I see the following prompt: </p> <pre><code>[venv] supervisor$ supervisord 2013-05-08 18:42:22,148 INFO RPC interface 'supervisor' initialized 2013-05-08 18:42:22,148 CRIT Server 'unix_http_server' running without any HTTP authentication checking 2013-05-08 18:42:22,149 INFO supervisord started with pid 6778 2013-05-08 18:42:23,152 INFO spawned: 'celeryd' with pid 6781 2013-05-08 18:42:23,156 INFO spawned: 'memcached' with pid 6782 2013-05-08 18:42:23,159 INFO spawned: 'backend' with pid 6783 2013-05-08 18:42:24,314 INFO success: celeryd entered RUNNING state, process has stayed up for &gt; than 1 seconds (startsecs) 2013-05-08 18:42:24,314 INFO success: memcached entered RUNNING state, process has stayed up for &gt; than 1 seconds (startsecs) 2013-05-08 18:42:24,314 INFO success: backend entered RUNNING state, process has stayed up for &gt; than 1 seconds (startsecs) </code></pre> <p>This is what pstree looks like:</p> <pre><code> | | \-+= 91117 vng -/bin/bash | | \-+= 06778 vng /Volumes/Data2/Dropbox/projects/Giordano/venv/bin/python /Volumes/Data2/Dropbox/projects/Giordano/venv/bin/supervisord | | |-+= 06781 vng /Volumes/Data2/Dropbox/projects/Giordano/venv/bin/python ../../../venv/bin/celery worker --app=tasks -l debug | | | |--- 06795 vng /Volumes/Data2/Dropbox/projects/Giordano/venv/bin/python ../../../venv/bin/celery worker --app=tasks -l debug | | | |--- 06796 vng /Volumes/Data2/Dropbox/projects/Giordano/venv/bin/python ../../../venv/bin/celery worker --app=tasks -l debug | | | |--- 06797 vng /Volumes/Data2/Dropbox/projects/Giordano/venv/bin/python ../../../venv/bin/celery worker --app=tasks -l debug | | | \--- 06798 vng /Volumes/Data2/Dropbox/projects/Giordano/venv/bin/python ../../../venv/bin/celery worker --app=tasks -l debug | | |--= 06782 vng memcached | | \-+= 06783 vng ../../../venv/bin/python backend.py | | \--- 06790 vng /Volumes/Data2/Dropbox/projects/Giordano/src/giordano/web/../../../venv/bin/python backend.py </code></pre> <p>killing supervisor results in: </p> <pre><code>^C2013-05-08 18:43:18,305 WARN received SIGINT indicating exit request 2013-05-08 18:43:18,305 INFO waiting for celeryd, memcached, backend to die 2013-05-08 18:43:18,352 INFO stopped: backend (exit status 0) 2013-05-08 18:43:18,353 INFO stopped: memcached (terminated by SIGTERM) 2013-05-08 18:43:18,414 INFO stopped: celeryd (exit status 0) </code></pre> <p>And out of no where, backend.py gets displaced in pstree: </p> <pre><code> |--= 41659 root /usr/libexec/taskgated -s |--- 42779 vng /usr/local/Cellar/erlang/R15B03-1/lib/erlang/erts-5.9.3.1/bin/epmd -daemon |--= 88518 root /usr/sbin/ocspd |--- 97815 vng /Applications/Dropbox.app/Contents/MacOS/Dropbox /firstrunupdate 403 |--= 97905 _usbmuxd /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/Resources/usbmuxd -launchd \--- 06790 vng /Volumes/Data2/Dropbox/projects/Giordano/src/giordano/web/../../../venv/bin/python backend.py </code></pre> <p>I am annoyed by this because every time I restart supervisord I am getting an error that the port is already being used. </p> <p>Anyone here knows what is causing this problem? </p> <p>EDIT: </p> <p>My backend.py</p> <pre><code>app = Flask(__name__) app.config.from_object(__name__) app.secret_key = 'asgasdasdgasd' app.debug = bool(int(os.environ.get("DEBUG", 1))) # DEBUG=0 if app.debug: from giordano.web import colorer # Needed for coloring logging app.config.update( MAIL_SERVER='smtp.gmail.com', MAIL_DEBUG=False, MAIL_PORT=465, MAIL_USE_SSL=True, MAIL_USERNAME = 'asdfasdfasdfasdfasdf@asdasdfas.com', MAIL_PASSWORD = 'asdfasdfasdfa' ) mail = Mail(app) # Very important to do it after!! log_level = logging.DEBUG if app.debug else logging.INFO logging.basicConfig(level=log_level, format='%(asctime)s %(levelname)s %(message)s') logging.info("Launching app with debug=%s" % app.debug) .... class TimedRequestHandler(BaseRequestHandler): """http://blog.sendhub.com/post/48832423565/hacking-flask-a-success-story """ def handle(self): self.fancyStarted = time.time() rv = super(TimedRequestHandler, self).handle() return rv def send_response(self, code, message=None): self.fancyProcessed = time.time() super(TimedRequestHandler, self).send_response(code, message=None) def log_request(self, code='-', size='-'): duration = int((self.fancyProcessed - self.fancyStarted) * 1000) line = '"{0}" {1} {2} [{3}ms]'.format(self.requestline, code, size, duration) self.log('info', line) if __name__ == "__main__": init_db() # run if you need to create tables app.run(host='0.0.0.0', port=8888, request_handler=TimedRequestHandler) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload