nginx/ubuntu deploy script: added uWSGI Emperor configuration

This commit is contained in:
zvolsky
2016-03-10 10:20:36 +01:00
parent 3999fd80f8
commit 43c60df371
+25 -4
View File
@@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
echo 'setup-web2py-nginx-uwsgi-ubuntu-precise.sh' echo 'setup-web2py-nginx-uwsgi-ubuntu-precise.sh'
echo 'Requires Ubuntu > 12.04 and installs Nginx + uWSGI + Web2py' echo 'Requires Ubuntu > 12.04 or Debian >= 8 and installs Nginx + uWSGI + Web2py'
# Check if user has root privileges # Check if user has root privileges
if [[ $EUID -ne 0 ]]; then if [[ $EUID -ne 0 ]]; then
echo "You must run the script as root or using sudo" echo "You must run the script as root or using sudo"
@@ -137,6 +137,26 @@ fi
# Prepare folders for uwsgi # Prepare folders for uwsgi
sudo mkdir /etc/uwsgi sudo mkdir /etc/uwsgi
sudo mkdir /var/log/uwsgi sudo mkdir /var/log/uwsgi
sudo mkdir /etc/systemd
sudo mkdir /etc/systemd/system
#uWSGI Emperor
echo '[Unit]
Description = uWSGI Emperor
After = syslog.target
[Service]
ExecStart = /usr/local/bin/uwsgi --ini /etc/uwsgi/web2py.ini
RuntimeDirectory = uwsgi
Restart = always
KillSignal = SIGQUIT
Type = notify
StandardError = syslog
NotifyAccess = all
[Install]
WantedBy = multi-user.target
' > /etc/systemd/system/emperor.uwsgi.service
# Create configuration file /etc/uwsgi/web2py.ini # Create configuration file /etc/uwsgi/web2py.ini
echo '[uwsgi] echo '[uwsgi]
@@ -192,17 +212,18 @@ if [ "$nopassword" -eq 0 ]
then then
sudo -u www-data python -c "from gluon.main import save_password; save_password('$PW',443)" sudo -u www-data python -c "from gluon.main import save_password; save_password('$PW',443)"
fi fi
start uwsgi-emperor systemctl enable emperor.uwsgi.service
systemctl start emperor.uwsgi.service
/etc/init.d/nginx restart /etc/init.d/nginx restart
echo <<EOF echo <<EOF
you can reload uwsgi with you can reload uwsgi with
restart uwsgi-emperor systemctl restart emperor.uwsgi
and stop it with and stop it with
stop uwsgi-emperor systemctl stop emperor.uwsgi
to reload web2py only (without restarting uwsgi) to reload web2py only (without restarting uwsgi)