Why is my script to start UWSGI not functioning at bootup?
<p>I wonder if you can help. </p>

<p>I am running the following versions: </p>

<pre><code>OS: SMP Debian 3.2.81-1 x86_64
uWSGI: uWSGI 2.0.11.2
</code></pre>

<p>I installed uWSGI manually, as I want to use a specific version. Using the following commands: - </p>

<pre><code>apt-get install build-essential psmisc python-dev libxml2 libxml2-dev python-setuptools
cd /opt/
wget http://projects.unbit.it/downloads/uwsgi-2.0.11.2.tar.gz
tar -zxvf uwsgi-2.0.11.2.tar.gz
mv uwsgi-2.0.11.2/ uwsgi/
cd uwsgi/
python setup.py install
</code></pre>

<p>I am trying to replicate the setup on another server that the project is already working on in a live environment (I am essentially setting up a test server environment). </p>

<p>The original server has uWSGI running on boot. To figure out how this is happening, I used</p>

<pre><code>htops 
</code></pre>

<p>I've been able to identify that uWSGI is running on the existing server with a set of command line switches. I've managed to track down the script that initialises uWSGI with these switches in the init.d folder. </p>

<p>I copied this script to my test server, and ran it using </p>

<pre><code>service script.sh start
</code></pre>

<p>After various troubleshooting, mainly involving permissions on socket folders etc, now when I run this script it starts, and if I run htop I can see uWSGI is running and it has the exact same command switches I need. </p>

<p>I thought simply putting the script in init.d and giving it execute permission </p>

<pre><code>chmod +x script.sh
</code></pre>

<p>Would be enough so that it starts when the server is switched on... but this appears to not be the case. Because when I issue</p>

<pre><code>reboot
</code></pre>

<p>At the terminal, the terminal reboots but when I go into htops, and check for the uWSGI process it is not running. </p>

<p>If however directly after reboot I issue the following command</p>

<pre><code>service script.sh start
</code></pre>

<p>The service starts just fine, and I can once again see it in htops. </p>

<p>Research online lead me to the suggestion that I should try to set the script to run automatically using chkconfig. I installed chkconfig using</p>

<pre><code>apt-get chkconfig
</code></pre>

<p>and then ran the following command</p>

<pre><code>chkconfig --list
</code></pre>

<p>I noticed that all the runtime levels where set to off for the script I am trying to get to execute on boot. </p>

<p>I ran the following command</p>

<pre><code>chkconfig /etc/init.d/script.sh on
</code></pre>

<p>And now when I check the script runtime switches with chkconfig, it shows me the following output for my script: </p>

<pre><code>script.sh               0:off  1:off  2:on   3:on   4:on   5:on   6:off
</code></pre>

<p>However when I reboot the uWSGI process is still not starting. </p>

<p>Yet if I simply type </p>

<pre><code>service script.sh start 
</code></pre>

<p>At the terminal the service runs ok, and uWSGI runs fine. </p>

<p>How can I set the script to run when the server restarts?</p>

<hr>

<p>Edit: </p>

<p>Further research on the live server that is working fine, has determined that it does not appear to be using systemd to launch uWSGI on startup. I logged into the live server and while there is a </p>

<pre><code>/etc/systemd 
</code></pre>

<p>folder, it has just one folder in it <code>system</code> and no files. The system folder has the following files in it: </p>

<pre><code>multi-user.target.wants  sockets.target.wants  syslog.service
</code></pre>

<p>So there does not appear to be anything uWSGI related in here. </p>

<p>Also what is making me think this is likely something to do with the </p>

<pre><code>/etc/init.d 
</code></pre>

<p>folder, is that when I run htop and examine the running services (or daemons) not quite sure of the correct terminology in linux. uWSGI is showing in here as running with a signature of command line switches, and the script I have found in <code>/etc/init.d</code> has this exact uWSGI command and same signature of switches, so I'm fairly convinced this is the part of the system that is starting the uWSGI daemon , I just can't figure out what I need to do , to get it to run apart from copying the same file to <code>/etc/init.d</code> on the new server and giving it execute permission. </p>

<p>The OS of the live server is : </p>

<pre><code>SMP Debian 3.2.73-2+deb7u1 x86_64
</code></pre>

<p>and the OS I am running on the new server is</p>

<pre><code>SMP Debian 3.2.81-1 x86_64
</code></pre>

<p>So they seem fairly similiar? Although I'm not sure how significant the 8 incremements in the least significant digits in the version number is. </p>

<p>On the new server there is no <code>/etc/systemd</code> folder , and on the live server there is a <code>/etc/systemd</code> as explained above. So it does appear to have been installed seperately to the main OS install (as I have a later version of Debian and it wasn't installed on my system by default) - so perhaps there is something related to systemd that is causing the script to start on the live server, but I'm not too sure. </p>