theoden avatar theoden committed 904e2f4

Rejected "testing" debian branch at all because of stability and security.

uWSGI is now installed via pip in semi-manual mode. It's init script is bundled
with django-fab-deploy for the moment.
(a variation around http://library.linode.com/assets/683-uwsgi-init-deb.sh)

Comments (0)

Files changed (4)

fab_deploy/config_templates/uwsgi_init

+#!/bin/sh
+### BEGIN INIT INFO
+# Provides:          uwsgi
+# Required-Start:    $all
+# Required-Stop:     $all
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: starts the uwsgi app server
+# Description:       starts uwsgi app server using start-stop-daemon
+### END INIT INFO
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+# в squeeze uwsgi живет именно тут!
+DAEMON=/usr/local/bin/uwsgi
+NAME=uwsgi
+DESC=uwsgi
+PIDFILE=/var/run/uwsgi/$NAME.pid
+
+test -x $DAEMON || exit 0
+
+# Include uwsgi defaults if available
+if [ -f /etc/default/uwsgi ] ; then
+        . /etc/default/uwsgi
+fi
+
+set -e
+
+DAEMON_OPTS="--emperor "/etc/uwsgi/apps-enabled/*.ini" --fastrouter 127.0.0.1:1336 --fastrouter-subscription-server 127.0.0.1:1337 --pidfile $PIDFILE --master --daemonize /var/log/uwsgi.log"
+
+case "$1" in
+  start)
+        echo -n "Starting $DESC: "
+        start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS
+        echo "$NAME."
+        ;;  
+  stop)
+        echo -n "Stopping $DESC: "
+        start-stop-daemon --signal 3 --pidfile $PIDFILE --retry 2 --stop \
+                --exec $DAEMON
+        echo "$NAME."
+        ;;
+  reload)
+        killall -1 $DAEMON
+        ;;
+  force-reload)
+        killall -15 $DAEMON
+       ;;
+  restart)
+        echo -n "Restarting $DESC: "
+        start-stop-daemon --signal 3 --pidfile $PIDFILE --retry 2 --stop \
+                --exec $DAEMON
+        sleep 1
+        start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS
+        echo "$NAME."
+        ;;
+  status)
+        killall -10 $DAEMON
+        ;;
+      *)
+            N=/etc/init.d/$NAME
+            echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2
+            exit 1
+            ;;
+    esac
+    exit 0

fab_deploy/db/mysql.py

         self._preseed_password(passwd)
 
         system.aptitude_install('mysql-server')
-        options = {'squeeze': '-t testing'}
-        system.aptitude_install(' '.join(extra_packages[os]), options.get(os, ''))
+        system.aptitude_install(' '.join(extra_packages[os]))
 
     @task_method
     def is_installed(self):

fab_deploy/system.py

         install_sudo()
 
     setup_backports()
-    setup_package_sources()
     install_software()
 
 @task
 
     sudo("echo 'deb %s' > /etc/apt/sources.list.d/backports.sources.list" % backports[os])
 
-@task
-@utils.run_as_sudo
-def setup_package_sources():
-    """ Adds additional repos to apt sources. """
-    os = utils.detect_os()
-    uwsgi = {
-        'lucid': 'http://ppa.launchpad.net/uwsgi/release/ubuntu lucid main',
-        'squeeze': 'http://ftp.ru.debian.org/debian testing main contrib non-free',
-    }
-    if os in uwsgi:
-        sudo("echo 'deb %s' > /etc/apt/sources.list.d/uwsgi.list" % uwsgi[os])
-    if os=='squeeze':
-        sudo('echo \'APT::Default-Release "stable";\' > /etc/apt/apt.conf.d/default')
     with settings(warn_only=True):
         sudo('aptitude update')
         env.conf._APTITUDE_UPDATED = True

fab_deploy/webserver/uwsgi.py

 # coding: utf-8
 from __future__ import with_statement, absolute_import
+import os
 
-from fabric.api import env, cd, sudo, prefix #run, settings, hide, abort
+from fabric.api import env, cd, sudo, prefix, put #run, settings, hide, abort
 #from fabric.contrib import files, console
 
 from taskset import task_method
     @utils.run_as_sudo
     def restart(self):
         """ Restarts uwsgi using init.d script. """
-        # here should be restart of the Emperor, but 
-        # for a moment here is restart of the concrete vassal
-        name = self._get_server_config_name()
-        sudo('invoke-rc.d uwsgi restart '+name)
+        sudo('invoke-rc.d uwsgi restart')
 
     @task_method
     def update_config(self):
         Returns whether uwsgi is running
         """
         return True # temporary plug
-        #with settings(hide('running', 'stdout', 'stderr', 'warnings'), warn_only=True):
-        #    output = sudo('invoke-rc.d apache2 status')
-        #return output.succeeded
+        with settings(hide('running', 'stdout', 'stderr', 'warnings'), warn_only=True):
+            output = sudo('invoke-rc.d uwsgi status')
+        return output.succeeded
 
     # ==== installation ===
 
     @utils.run_as_sudo
     def install(self, confirm=True):
         """ Installs uwsgi. """
-        os = utils.detect_os()
-        options = {'squeeze': '-t testing'}
-        if os=='squeeze':
-            # We need to preseed libc interactive prompt. It popups since uwsgi
-            # pulls its upgrade to version from Wheezy.
-            # E.g. see http://www.50ply.com/blog/2012/07/16/automating-debian-installs-with-preseed-and-puppet/
-            system.aptitude_install('debconf-utils')
-            sudo("echo '%s' | debconf-set-selections" % 'libc6 libraries/restart-without-asking boolean true')
-        # Also we need to turn-off apt-listchanges as it reduces automation.
-        with prefix('export APT_LISTCHANGES_FRONTEND=text'):
-            system.aptitude_install('uwsgi uwsgi-plugin-python', options.get(os, ''))
+        os_name = utils.detect_os()
+        sudo('pip install uwsgi')
+        sudo('mkdir -p /etc/uwsgi/apps-available')
+        sudo('mkdir -p /etc/uwsgi/apps-enabled')
+        sudo('mkdir -p /var/run/uwsgi')
+        local_initd = utils._data_path(os.path.join('config_templates', 'uwsgi_init'))
+        put(local_initd, '/etc/init.d/uwsgi', use_sudo=True, mode=0755)
+        sudo('invoke-rc.d uwsgi start')
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.