Last active
December 16, 2018 03:05
-
-
Save milnomada/120e677a076c4ee776cefcb5f1efd531 to your computer and use it in GitHub Desktop.
Prepare uwsgi environment for Ubuntu 14.04 or 16.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Install pip installing | |
wget https://bootstrap.pypa.io/get-pip.py | |
sudo python get-pip.py | |
# Necessary gcc to install uwsgi | |
sudo apt-get install -y gcc git openssl | |
sudo pip install virtualenv | |
sudo apt-get install -y python3.5-dev python-dev | |
sudo apt-get install -y libffi-dev | |
sudo apt-get install -y libssl-dev | |
sudo apt-get install -y libxml2 | |
# Need python-dev libs | |
sudo pip install uwsgi | |
if [ $(lsb_release -rs) = '16.04' ] ; then | |
## Add service for Ubuntu 16.04 | |
printf "Ubuntu 16.04 install\n" | |
sudo mkdir /var/log/uwsgi | |
srvfile=/etc/systemd/system/uwsgi.service | |
appsfolder=/opt/apps | |
logger1=file:/var/log/uwsgi/emperor.log | |
#logger2= | |
sudo touch $srvfile | |
echo "[Unit]" | sudo tee -a $srvfile | |
echo "Description=uWSGI Emperor service" | sudo tee -a $srvfile | |
echo "[Service]" | sudo tee -a $srvfile | |
echo "User=uwsgi" | sudo tee -a $srvfile | |
echo "Group=www-data" | sudo tee -a $srvfile | |
# ExecStartPre=/bin/bash -c 'mkdir -p /run/uwsgi; chown uwsgi:www-data /run/uwsgi' | |
echo "ExecStart=/usr/local/bin/uwsgi --emperor $appsfolder --emperor-nofollow --logger $logger1 --enable-threads" | sudo tee -a $srvfile | |
# --logger $logger2 | |
echo "Restart=always" | sudo tee -a $srvfile | |
echo "KillSignal=SIGQUIT" | sudo tee -a $srvfile | |
echo "Type=notify" | sudo tee -a $srvfile | |
echo "NotifyAccess=all" | sudo tee -a $srvfile | |
echo "[Install]" | sudo tee -a $srvfile | |
echo "WantedBy=multi-user.target" | sudo tee -a $srvfile | |
printf "Done.\n" | |
sudo systemctl restart uwsgi | |
else | |
printf "Ubuntu 14.04 install\n" | |
srvfile=/etc/init/uwsgi.conf | |
sudo touch $srvfile | |
echo "# uWSGI" | sudo tee -a $srvfile | |
echo "description 'uWSGI Emperor'" | sudo tee -a $srvfile | |
echo "start on (filesystem and net-device-up IFACE=lo)" | sudo tee -a $srvfile | |
echo "stop on runlevel [!2345]" | sudo tee -a $srvfile | |
echo "post-stop exec sleep 1" | sudo tee -a $srvfile | |
echo "respawn" | sudo tee -a $srvfile | |
echo "env LOGTO=/var/log/emperor.log" | sudo tee -a $srvfile | |
echo "env BINPATH=/usr/local/bin/uwsgi" | sudo tee -a $srvfile | |
echo "env SYLG=syslog:uwsgi,local6" | sudo tee -a $srvfile | |
echo "exec $BINPATH --emperor /srv/vassals --emperor-nofollow --logger file:$LOGTO --logger:$SYLG --enable-threads" | sudo tee -a $srvfile | |
printf "Done.\n" | |
sudo service uwsgi restart | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment