title: Uwsgi emperor has no vassals
body: <p>I am trying to set up nginx to work with uwsgi, I am on Arch Linux. I have /etc/uwsgi/emperor.ini and /etc/uwsgi/vassals/myapp.ini. My emperor.ini looks like: </p>
  
  <pre><code>[uwsgi]
  emperor = /etc/uwsgi/vassals
  emperor-pidfile = /run/uwsgi/uwsgi.pid
  uid = http
  gid = http
  logto = /var/log/uwsgi/uwsgi.log
  </code></pre>
  
  <p>myapp.ini</p>
  
  <pre><code>[uwsgi]
  chdir = /srv/http/myapp/src/
  wsgi-file = run.py
  callable = app
  processes = 4
  threads = 2
  offload-threads = 2
  stats =  127.0.0.1:9191
  max-requests = 5000
  master = True
  vacuum = True
  socket = 127.0.0.1:3031
  enable-threads = true
  harakiri = 60
  logto = /var/log/uwsgi/myapp.log
  </code></pre>
  
  <p>uwsgi.service [for systemd]</p>
  
  <pre><code>[Unit]
  Description=uWSGI Emperor
  After=syslog.target
  
  [Service]
  PIDFile=/run/uwsgi/uwsgi.pid
  ExecStartPre=/bin/mkdir -p /run/uwsgi
  ExecStartPre=/bin/chown http:http /run/uwsgi
  ExecStart=/usr/bin/uwsgi --ini /etc/uwsgi/emperor.ini
  Restart=always
  Type=notify
  StandardError=syslog
  NotifyAccess=main
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  
  <p>Yet when the uwsgi.service runs I get:</p>
  
  <pre><code>uwsgi.service - uWSGI Emperor
     Loaded: loaded (/etc/systemd/system/uwsgi.service; disabled)
     Active: active (running) since Sun 2014-02-02 04:37:04 PST; 34min ago
    Process: 31537 ExecStartPre=/bin/chown http:http /run/uwsgi (code=exited, status=0/SUCCESS)
    Process: 31535 ExecStartPre=/bin/mkdir -p /run/uwsgi (code=exited, status=0/SUCCESS)
   Main PID: 31540 (uwsgi)
     Status: "The Emperor is governing 0 vassals"
     CGroup: /system.slice/uwsgi.service
             ââ31540 /usr/bin/uwsgi --ini /etc/uwsgi/emperor.ini
  
  Feb 02 04:37:04 MyMachine uwsgi[31540]: [uWSGI] getting INI configuration from /etc/uwsgi/emperor.ini
  Feb 02 04:37:04 MyMachine systemd[1]: Started uWSGI Emperor.
  </code></pre>
  
  <p>That bit right there? "The Emperor is governing 0 vassals" for some reason it will not look at the myapp.ini in the vassal directory.  This is what I get in a command line "log":</p>
  
  <pre><code>*** Starting uWSGI 2.0 (64bit) on [Sun Feb  2 05:27:37 2014] ***
  compiled with version: 4.8.2 20131219 (prerelease) on 09 January 2014 11:43:55
  os: Linux-3.12.7-2-ARCH #1 SMP PREEMPT Sun Jan 12 13:09:09 CET 2014
  nodename: MyMachine
  machine: x86_64
  clock source: unix
  pcre jit disabled
  detected number of CPU cores: 2
  current working directory: /home/me
  detected binary path: /usr/bin/uwsgi
  your processes number limit is 26743
  your memory page size is 4096 bytes
   *** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers ***
  detected max file descriptor number: 1024
  lock engine: pthread robust mutexes
  thunder lock: disabled (you can enable it with --thunder-lock)
  uwsgi socket 0 bound to TCP address 127.0.0.1:3031 fd 3
  Python version: 2.7.6 (default, Nov 26 2013, 12:52:49)  [GCC 4.8.2]
  Python main interpreter initialized at 0xcfd340
  python threads support enabled
  your server socket listen backlog is limited to 100 connections
  your mercy for graceful operations on workers is 60 seconds
  mapped 415280 bytes (405 KB) for 8 cores
  *** Operational MODE: preforking+threaded ***
  WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0xcfd340 pid: 32089 (default app)
  *** uWSGI is running in multiple interpreter mode ***
  spawned uWSGI master process (pid: 32089)
  spawned uWSGI worker 1 (pid: 32092, cores: 2)
  spawned 2 offload threads for uWSGI worker 1
  spawned uWSGI worker 2 (pid: 32095, cores: 2)
  spawned uWSGI worker 3 (pid: 32097, cores: 2)
  spawned 2 offload threads for uWSGI worker 3
  spawned uWSGI worker 4 (pid: 32100, cores: 2)
  spawned 2 offload threads for uWSGI worker 2
  spawned 2 offload threads for uWSGI worker 4
  </code></pre>
  
  <p>I cannot seem to get uwsgi to run see its vassals no matter what I do. Thanks.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>OK so I decided to go back to the command line so I don't have to deal with log and pid permission errors and I noticed something strange. When I make write out <strong>uwsgi --ini /etc/uwsgi/emperor.ini</strong> the entire thing works, I can access the site through nginx, beautiful, but I saw this in the console output:</p>
  
  <pre><code>    *** Starting uWSGI 2.0 (64bit) on [Sun Feb  2 15:19:43 2014] ***
  compiled with version: 4.8.2 20131219 (prerelease) on 09 January 2014 11:43:55
  os: Linux-3.12.9-2-ARCH #1 SMP PREEMPT Fri Jan 31 10:22:54 CET 2014
  nodename: MyMachine
  machine: x86_64
  clock source: unix
  pcre jit disabled
  detected number of CPU cores: 2
  current working directory: /home/me
  detected binary path: /usr/bin/uwsgi
  *** WARNING: you are running uWSGI without its master process manager ***
  your processes number limit is 26743
  your memory page size is 4096 bytes
  detected max file descriptor number: 1024
  *** starting uWSGI Emperor ***
  *** has_emperor mode detected (fd: 5) ***
  [uWSGI] getting INI configuration from /etc/uwsgi/emperor.ini
  *** Starting uWSGI 2.0 (64bit) on [Sun Feb  2 15:19:43 2014] ***
  compiled with version: 4.8.2 20131219 (prerelease) on 09 January 2014 11:43:55
  os: Linux-3.12.9-2-ARCH #1 SMP PREEMPT Fri Jan 31 10:22:54 CET 2014
  nodename: MyMachine
  machine: x86_64
  clock source: unix
  pcre jit disabled
  detected number of CPU cores: 2
  current working directory: /home/me
  detected binary path: /usr/bin/uwsgi
  your processes number limit is 26743
  your memory page size is 4096 bytes
  detected max file descriptor number: 1024
  lock engine: pthread robust mutexes
  thunder lock: disabled (you can enable it with --thunder-lock)
  *** starting uWSGI sub-Emperor ***
  Python version: 2.7.6 (default, Nov 26 2013, 12:52:49)  [GCC 4.8.2]
  *** has_emperor mode detected (fd: 7) ***
  [uWSGI] getting INI configuration from myapp.ini
  *** Starting uWSGI 2.0 (64bit) on [Sun Feb  2 15:19:43 2014] ***
  compiled with version: 4.8.2 20131219 (prerelease) on 09 January 2014 11:43:55
  os: Linux-3.12.9-2-ARCH #1 SMP PREEMPT Fri Jan 31 10:22:54 CET 2014
  nodename: MyMachine
  machine: x86_64
  clock source: unix
  pcre jit disabled
  detected number of CPU cores: 2
  current working directory: /etc/uwsgi/vassals
  detected binary path: /usr/bin/uwsgi
  your processes number limit is 26743
  your memory page size is 4096 bytes
   *** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers ***
  detected max file descriptor number: 1024
  lock engine: pthread robust mutexes
  thunder lock: disabled (you can enable it with --thunder-lock)
  uwsgi socket 0 bound to TCP address 127.0.0.1:3031 fd 3
  Python version: 2.7.6 (default, Nov 26 2013, 12:52:49)  [GCC 4.8.2]
  *** Python threads support is disabled. You can enable it with --enable-threads ***
  Python main interpreter initialized at 0x2403ab0
  your mercy for graceful operations on workers is 60 seconds
  *** Operational MODE: no-workers ***
  spawned uWSGI master process (pid: 1640)
  Sun Feb  2 15:19:43 2014 - [emperor] vassal /etc/uwsgi/emperor.ini has been spawned
  Python main interpreter initialized at 0x17682a0
  python threads support enabled
  your server socket listen backlog is limited to 100 connections
  your mercy for graceful operations on workers is 60 seconds
  mapped 415280 bytes (405 KB) for 8 cores
  *** Operational MODE: preforking+threaded ***
  WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x17682a0 pid: 1642 (default app)
  *** uWSGI is running in multiple interpreter mode ***
  spawned uWSGI master process (pid: 1642)
  Sun Feb  2 15:19:45 2014 - [emperor] vassal myapp.ini has been spawned
  spawned uWSGI worker 1 (pid: 1645, cores: 2)
  spawned 2 offload threads for uWSGI worker 1
  spawned uWSGI worker 2 (pid: 1648, cores: 2)
  Sun Feb  2 15:19:45 2014 - [emperor] vassal myapp.ini is ready to accept requests
  spawned 2 offload threads for uWSGI worker 2
  spawned uWSGI worker 3 (pid: 1651, cores: 2)
  spawned 2 offload threads for uWSGI worker 3
  spawned uWSGI worker 4 (pid: 1657, cores: 2)
  *** Stats server enabled on 127.0.0.1:9191 fd: 16 ***
  spawned 2 offload threads for uWSGI worker 4
  [pid: 1648|app: 0|req: 1/1] 192.168.1.156 () {40 vars in 795 bytes} [Sun Feb  2 15:20:40 2014] GET /articles =&gt; generated 2943 bytes in 164 msecs (HTTP/1.1 200) 3 headers in 283 bytes (1 switches on core 0)
  announcing my loyalty to the Emperor...
  Sun Feb  2 15:20:40 2014 - [emperor] vassal myapp.ini is now loyal
  [pid: 1657|app: 0|req: 1/2] 192.168.1.156 () {40 vars in 792 bytes} [Sun Feb  2 15:20:41 2014] GET /index =&gt; generated 3216 bytes in 184 msecs (HTTP/1.1 200) 3 headers in 283 bytes (1 switches on core 0)
  announcing my loyalty to the Emperor...
  Sun Feb  2 15:20:42 2014 - [emperor] vassal myapp.ini is now loyal
  </code></pre>
  
  <p>I started noticing some odd ball behavior in the output. I finally came down to this configuration which let's me see my site.</p>
  
  <p>emperor.ini</p>
  
  <pre><code>[uwsgi]
  emperor = /etc/uwsgi/vassals
  master = true
  #gid = http
  #uid = http
  </code></pre>
  
  <p>I commented out the gid and uid because with them there I get a bad gateway response when I try to connect to my website, it warns me about it in the log <em>uWSGI running as root, you can use --uid/--gid/--chroot options</em> but I am not sure what to do about it.</p>
  
  <p>myapp.ini</p>
  
  <pre><code>[uwsgi]
  chdir = /srv/http/myapp/src/
  wsgi-file = run.py
  callable = app
  processes = 4
  threads = 2
  offload-threads = 2
  stats =  127.0.0.1:9191
  max-requests = 5000
  master = true
  vacuum = true
  socket = 127.0.0.1:3031
  harakiri = 60
  </code></pre>
  
  <p>uwsgi.service</p>
  
  <pre><code>[Unit]
  Description=uWSGI Emperor
  After=syslog.target
  
  [Service]
  ExecStart=/usr/bin/uwsgi --ini /etc/uwsgi/emperor.ini --enable-threads
  Restart=always
  KillSignal=SIGQUIT
  Type=notify
  StandardError=syslog
  NotifyAccess=main
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  
  <p>No idea what to do about it running as root.</p>