[Flask] errors w/ flask deployment with emperor
tigernassau
tigernassau at gmail.com
Tue Oct 20 19:10:55 EDT 2015
thks
okay we can try "module" - hmm, will app.py do ? or do we need to use
__init__.py ? and spec python3 ? right now our __init__.py is empty
is it a good idea to run emperor as root ? run anything as root ? when
we ran a test, it gave us a warning msg about running as root
On 10/20/2015 01:25 PM, Jeff Widman wrote:
> A few quick things I noticed:
> - no need to set Master = True in your Emperor because functionally
> the Emperor IS the master process. I submitted a pull request to the
> uWSGI docs clarifying this last week.
> - Emperor is generally run as root, with the vassals specifying their
> UID/GID. That lets the Emperor respawn vassals for various
> UID/GID's--for security, it will drop the vassal's privileges before
> actually serving requests
>
> I noticed you're trying to call Flask using the 'file' + 'callable'
> params. Typically most examples I've seen just use 'module' +
> 'callable'. I haven't looked into the 'file' param, it may do the same
> thing. The most important part is making sure you're calling whatever
> it is that starts your app... sometimes people subclass app in a
> different file, particularly if they're using the app factory pattern
> for quickly switching between dev and prod configuration.
>
> To debug, I'd first try running the Flask development webserver, and
> make sure it loads. That should allow you to trace whether you should
> be calling 'app' or a different command. Then try the vassal by itself
> using the shell and see if it loads, then if that works then add the
> emperor, then if that all works, then go to daemonizing it using SystemD.
>
> Cheers,
> Jeff
>
> ᐧ
>
> On Tue, Oct 20, 2015 at 11:34 AM, tigernassau <tigernassau at gmail.com
> <mailto:tigernassau at gmail.com>> wrote:
>
> okay, we took another try at getting flask to deploy using emperor
> server: debian 8, using python3
>
> server runs bottle apps fine
>
> here is the config we tried - get error: "curse the vassal...
> /etc/uwsgi/vassals/testapp.ini
> couldn't find any more details on what is wrong
>
> btw had to run uwsgi emperor as sudo since the systemd service
> failed with log file permission error
>
> ---- w/ flask ---
> # sudo apt-get install python3-dev
> # sudo apt-get install python3-pip
> # sudo pip3 install flask
> # sudo pip3 install py-bcrypt
> # sudo pip3 install psycopg2
> # sudo pip3 install uwsgi
> # sudo apt-get install uwsgi-plugin-python
>
> sudo vim /etc/nginx/nginx.conf
> user nginx;
> worker processes 5
> .....
> http {
> ...
> server {
> listen 80;
> server_name testapp.com <http://testapp.com>
> www.testapp.com <http://www.testapp.com>;
> root /home/testapp;
> charset utf-8;
> location /static {
> alias /home/testapp/static;
> }
> location = /favico.ico {
> root /home/testapp/static/images/favico.ico;
> }
> location / {
> try_files $uri @wsgi;
> }
> location @wsgi {
> include /etc/nginx/uwsgi_params;
> uwsgi_pass unix:/home/testapp/testapp.sock;
> }
> }
> } #http
> sudo service nginx configtest
> sudo service nginx start (stop reload)
>
> ---- uwsgi-emperor ---
> sudo vim /etc/uwsgi/emperor.ini
> [uwsgi]
> emperor = /etc/uwsgi/vassals
> master = true
> #plugins = python2
> #uid = www-data
> #gid = www-data
>
> --- uwsgi vassals ---
> sudo vim /etc/uwsgi/vassals/testapp.ini
> [uwsgi]
> chdir = /home/testapp
> socket = /home/testapp/testapp.sock
> chmod-socket = 664
> file = app.py
> callable = app
> processes = 4
> stats = 127.0.0.1:9191 <http://127.0.0.1:9191>
> max-requests = 5000
> #master = true
> #plugins = python
> #uid = www-data
> #gid = www-data
> vacuum = true
> thunder-lock = true
> enable-threads = true
> logto = /var/log/uwsgi/testapp.log
> # die-on-term = true
>
> ---- systemd service emperor ---
> sudo vim /etc/systemd/system/testapp.service
> [Unit]
> Description=uwsgi emperor for testapp
> After=network.target
> [Service]
> User=www-data
> Group=www-data
> WorkingDirectory=/home/testapp
> ExecStart=uwsgi --emperor /etc/uwsgi/vassals/testapp.ini --logto
> /var/log/uwsgi/testapp.log
> #[Install]
> #WantedBy=multi-user.target
>
>
>
>
>
>
> --
> Tiger Nassau, Inc.
> www.tigernassau.com <http://www.tigernassau.com>
>
> _______________________________________________
> Flask mailing list
> Flask at python.org <mailto:Flask at python.org>
> https://mail.python.org/mailman/listinfo/flask
>
>
>
>
> --
> *
> Jeff Widman*
> jeffwidman.com <http://www.jeffwidman.com/> | 740-WIDMAN-J (943-6265)
> <><
--
Tiger Nassau, Inc.
www.tigernassau.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20151020/116d37ea/attachment-0001.html>
More information about the Flask
mailing list