Difference between revisions of "Flask"
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== | ====running app forever - supervisorctl==== | ||
cascada | |||
:port = 8087 | |||
:/home/pi/mypi/cascada/server/cascada.py | |||
cascada2 | |||
:port = 8088 | |||
:/home/pi/mypi/cascada/server/cascada2.py | |||
<markdown> | |||
= | |||
/home/pi/mypi/cascada/server/cascada. | sudo`supervisorctl` reads configuration from `/etc/supervisor/conf.d` and runs whatever files if finds there. | ||
a typical `conf` ile looks like: | |||
[program:cascada2] | |||
command=/usr/bin/python /home/pi/mypi/cascada/server/cascada2.py | |||
directory=/home/pi/mypi/cascada/server | |||
autostart=true | |||
autorestart=true | |||
startretries=3 | |||
stderr_logfile=/var/log/cascada/cascada2.err.log | |||
stdout_logfile=/var/log/cascada/cascada2.out.log | |||
user=root | |||
environment=SECRET_PASSPHRASE='this is secret',SECRET_TWO='another secret' | |||
you may have to `>supervisor reload` then `ctrl c` the `sudo supervisorctl` to get a new program running forever | |||
</markdown> | |||
pi@raspberrypi ~ $ sudo supervisorctl | pi@raspberrypi ~ $ sudo supervisorctl | ||
Line 39: | Line 60: | ||
[https://serversforhackers.com/monitoring-processes-with-supervisord forever with supervisord] | [https://serversforhackers.com/monitoring-processes-with-supervisord forever with supervisord] | ||
{{:sse}} | |||
{{:socketio}} | {{:socketio}} | ||
Latest revision as of 10:06, 19 August 2015
running app forever - supervisorctl
cascada
- port = 8087
- /home/pi/mypi/cascada/server/cascada.py
cascada2
- port = 8088
- /home/pi/mypi/cascada/server/cascada2.py
<markdown>
sudo`supervisorctl` reads configuration from `/etc/supervisor/conf.d` and runs whatever files if finds there.
a typical `conf` ile looks like:
[program:cascada2] command=/usr/bin/python /home/pi/mypi/cascada/server/cascada2.py directory=/home/pi/mypi/cascada/server autostart=true autorestart=true startretries=3 stderr_logfile=/var/log/cascada/cascada2.err.log stdout_logfile=/var/log/cascada/cascada2.out.log user=root environment=SECRET_PASSPHRASE='this is secret',SECRET_TWO='another secret'
you may have to `>supervisor reload` then `ctrl c` the `sudo supervisorctl` to get a new program running forever
</markdown>
pi@raspberrypi ~ $ sudo supervisorctl cascada RUNNING pid 2273, uptime 7 days, 3:17:36
tail -f /var/log/cascada/cascada.out.log tail -f /var/log/cascada/cascada.err.log
after changing cascada.py
pi@raspberrypi ~ $ sudo supervisorctl cascada RUNNING pid 2273, uptime 7 days, 3:17:36 supervisor> stop cascada
exit w ctrl C
sudo lsof -i :8087 sudo kill -9 21118 (kill whatever port lsof returns)
pi@raspberrypi ~ $ sudo supervisorctl cascada STOPPED Jul 16 04:34 PM supervisor> start cascada cascada: started supervisor>
exit w ctrl C ??
- nohup python app.py &
- use screen
- run supervisord(link) on system startup and control all through it (pythonic way :))
nohup means: do not terminate this process even when the stty is cut off.
& at the end means: run this command as a background task.
SSE - Server Side Events
http://flask.pocoo.org/snippets/116/
https://github.com/stevenewey/ssedemo
for node
https://www.npmjs.com/package/simple-sse (has room,haven't tried)
https://tomkersten.com/articles/server-sent-events-with-node/
http://www.futureinsights.com/home/real-time-the-easy-way-with-eventsource-angularjs-and-nodejs.html
SocketIO
http://stackoverflow.com/questions/17641602/how-to-emit-to-room-in-socket-io