<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">thks<br>
      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<br>
      <br>
      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<br>
      <br>
      <br>
      <br>
      <br>
      On 10/20/2015 01:25 PM, Jeff Widman wrote:<br>
    </div>
    <blockquote
cite="mid:CABPX=-4aPpgvu9405w0-Q2H9vkukk5tMCY3UEAa7jG-44tdZQQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">A few quick things I noticed:
        <div> - 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. </div>
        <div> - 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</div>
        <div><br>
        </div>
        <div>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.</div>
        <div><br>
        </div>
        <div>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. </div>
        <div><br>
        </div>
        <div>Cheers,</div>
        <div>Jeff</div>
        <div><br>
        </div>
        <div hspace="streak-pt-mark" style="max-height:1px"><img
            moz-do-not-send="true"
            style="width:0px;max-height:0px;overflow:hidden"
src="https://mailfoogae.appspot.com/t?sender=aamVmZkBqZWZmd2lkbWFuLmNvbQ%3D%3D&type=zerocontent&guid=3479169e-074c-4710-be63-e0fa51bfbe10"><font
            color="#ffffff" size="1">ᐧ</font></div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Tue, Oct 20, 2015 at 11:34 AM,
          tigernassau <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:tigernassau@gmail.com" target="_blank">tigernassau@gmail.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">okay, we
            took another try at getting flask to deploy using emperor<br>
            server: debian 8, using python3<br>
            <br>
            server runs bottle apps fine<br>
            <br>
            here is the config we tried - get error:  "curse the
            vassal... /etc/uwsgi/vassals/testapp.ini<br>
            couldn't find any more details on what is wrong<br>
            <br>
            btw had to run uwsgi emperor as sudo since the systemd
            service failed with log file permission error<br>
            <br>
            ---- w/ flask ---<br>
            # sudo apt-get install python3-dev<br>
            # sudo apt-get install python3-pip<br>
            # sudo pip3 install flask<br>
            # sudo pip3 install py-bcrypt<br>
            # sudo pip3 install psycopg2<br>
            # sudo pip3 install uwsgi<br>
            # sudo apt-get install uwsgi-plugin-python<br>
            <br>
            sudo vim /etc/nginx/nginx.conf<br>
              user nginx;<br>
              worker processes 5<br>
              .....<br>
              http {<br>
                 ...<br>
                  server {<br>
                      listen 80;<br>
                      server_name <a moz-do-not-send="true"
              href="http://testapp.com" rel="noreferrer" target="_blank">testapp.com</a>
            <a moz-do-not-send="true" href="http://www.testapp.com"
              rel="noreferrer" target="_blank">www.testapp.com</a>;<br>
                      root /home/testapp;<br>
                      charset utf-8;<br>
                      location /static {<br>
                          alias /home/testapp/static;<br>
                      }<br>
                      location = /favico.ico  {<br>
                        root /home/testapp/static/images/favico.ico;<br>
                      }<br>
                      location / {<br>
                          try_files $uri @wsgi;<br>
                      }<br>
                      location @wsgi {<br>
                          include /etc/nginx/uwsgi_params;<br>
                          uwsgi_pass unix:/home/testapp/testapp.sock;<br>
                      }<br>
                  }<br>
              }  #http<br>
            sudo service nginx configtest<br>
            sudo service nginx start (stop reload)<br>
            <br>
            ---- uwsgi-emperor ---<br>
            sudo vim /etc/uwsgi/emperor.ini<br>
            [uwsgi]<br>
            emperor = /etc/uwsgi/vassals<br>
            master = true<br>
            #plugins = python2<br>
            #uid = www-data<br>
            #gid = www-data<br>
            <br>
            --- uwsgi vassals ---<br>
            sudo vim /etc/uwsgi/vassals/testapp.ini<br>
              [uwsgi]<br>
              chdir = /home/testapp<br>
              socket = /home/testapp/testapp.sock<br>
              chmod-socket = 664<br>
              file = app.py<br>
              callable = app<br>
              processes = 4<br>
              stats = <a moz-do-not-send="true"
              href="http://127.0.0.1:9191" rel="noreferrer"
              target="_blank">127.0.0.1:9191</a><br>
              max-requests = 5000<br>
              #master = true<br>
              #plugins = python<br>
              #uid = www-data<br>
              #gid = www-data<br>
              vacuum = true<br>
              thunder-lock = true<br>
              enable-threads = true<br>
              logto = /var/log/uwsgi/testapp.log<br>
              # die-on-term = true<br>
            <br>
            ---- systemd service emperor ---<br>
            sudo vim /etc/systemd/system/testapp.service<br>
              [Unit]<br>
                  Description=uwsgi emperor for testapp<br>
                  After=network.target<br>
              [Service]<br>
                  User=www-data<br>
                  Group=www-data<br>
                  WorkingDirectory=/home/testapp<br>
                  ExecStart=uwsgi --emperor
            /etc/uwsgi/vassals/testapp.ini --logto<br>
                      /var/log/uwsgi/testapp.log<br>
              #[Install]<br>
              #WantedBy=multi-user.target<span class="HOEnZb"><font
                color="#888888"><br>
                <br>
                <br>
                <br>
                <br>
                <br>
                <br>
                -- <br>
                Tiger Nassau, Inc.<br>
                <a moz-do-not-send="true"
                  href="http://www.tigernassau.com" rel="noreferrer"
                  target="_blank">www.tigernassau.com</a><br>
                <br>
                _______________________________________________<br>
                Flask mailing list<br>
                <a moz-do-not-send="true" href="mailto:Flask@python.org"
                  target="_blank">Flask@python.org</a><br>
                <a moz-do-not-send="true"
                  href="https://mail.python.org/mailman/listinfo/flask"
                  rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/flask</a><br>
              </font></span></blockquote>
        </div>
        <br>
        <br clear="all">
        <div><br>
        </div>
        -- <br>
        <div class="gmail_signature">
          <div dir="ltr">
            <div><b><br>
                Jeff Widman</b></div>
            <div><a moz-do-not-send="true"
                href="http://www.jeffwidman.com/" target="_blank">jeffwidman.com</a> | <a
                moz-do-not-send="true" value="+15102897784"
                style="color:rgb(17,85,204)">740-WIDMAN-J (943-6265)</a> </div>
            <div><><</div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Tiger Nassau, Inc.
<a class="moz-txt-link-abbreviated" href="http://www.tigernassau.com">www.tigernassau.com</a></pre>
  </body>
</html>