From 56359cce270aed0162a5f36739298812769a80d9 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Fri, 22 Nov 2013 11:05:51 +0700 Subject: [PATCH] new: added ``rsted`` charm. --- precise/rsted/hooks/install | 51 +++++++++++++++++++++++++ precise/rsted/hooks/start | 3 ++ precise/rsted/hooks/stop | 3 ++ precise/rsted/metadata.yaml | 8 ++++ precise/rsted/revision | 1 + precise/rsted/src/etc/init/rsted.conf | 18 +++++++++ precise/rsted/src/etc/logrotate.d/rsted | 13 +++++++ precise/rsted/src/etc/rsted/settings.py | 14 +++++++ 8 files changed, 111 insertions(+) create mode 100755 precise/rsted/hooks/install create mode 100755 precise/rsted/hooks/start create mode 100755 precise/rsted/hooks/stop create mode 100644 precise/rsted/metadata.yaml create mode 100644 precise/rsted/revision create mode 100644 precise/rsted/src/etc/init/rsted.conf create mode 100644 precise/rsted/src/etc/logrotate.d/rsted create mode 100644 precise/rsted/src/etc/rsted/settings.py diff --git a/precise/rsted/hooks/install b/precise/rsted/hooks/install new file mode 100755 index 00000000..308d8695 --- /dev/null +++ b/precise/rsted/hooks/install @@ -0,0 +1,51 @@ +#!/bin/bash + + +RSTED_USER=${RSTED_USER:-rsted} +RSTED_GROUP=${RSTED_GROUP:-rsted} + +## +## Installation code +## + +source /srv/virtualenv/default/bin/activate +set -eux # -x for verbose logging to juju debug-log + + +mkdir -p /opt/apps +( + cd /opt/apps && + git clone https://github.com/anru/rsted.git && + adduser --system --home=/home/"$RSTED_USER" --group "$RSTED_GROUP" && + #chown "$RSTED_USER":"$RSTED_GROUP" /opt/apps/rsted -R && + ## -H is to force HOME environment variable to change to etherpad one. + cd rsted && + pip install -r pip-requirements.txt +) + + +## +## Config file +## + +config_file="/etc/rsted/settings.py" + +[ -e "$config_file" ] || cp "src/etc/rsted/settings.py" "$config_file" + +ln -sf "$config_file" /opt/apps/rsted/settings_local.py + + +## +## Startup file +## + +cp src/etc/init/rsted.conf /etc/init/rsted.conf + +## +## Logrotate +## + +cp src/etc/logrotate.d/rsted /etc/logrotate.d/rsted + + + diff --git a/precise/rsted/hooks/start b/precise/rsted/hooks/start new file mode 100755 index 00000000..9eb7853c --- /dev/null +++ b/precise/rsted/hooks/start @@ -0,0 +1,3 @@ +#!/bin/bash + +juju-log "Nothing to Start for base." diff --git a/precise/rsted/hooks/stop b/precise/rsted/hooks/stop new file mode 100755 index 00000000..170162bd --- /dev/null +++ b/precise/rsted/hooks/stop @@ -0,0 +1,3 @@ +#!/bin/bash + +juju-log "Nothing to stop for base." diff --git a/precise/rsted/metadata.yaml b/precise/rsted/metadata.yaml new file mode 100644 index 00000000..58c44a9f --- /dev/null +++ b/precise/rsted/metadata.yaml @@ -0,0 +1,8 @@ +name: rsted +summary: "Rest server" +maintainer: "Valentin Lab " +inherit: python-venv +description: | + Restructured only editor +config-resources: + - /etc/rsted diff --git a/precise/rsted/revision b/precise/rsted/revision new file mode 100644 index 00000000..573541ac --- /dev/null +++ b/precise/rsted/revision @@ -0,0 +1 @@ +0 diff --git a/precise/rsted/src/etc/init/rsted.conf b/precise/rsted/src/etc/init/rsted.conf new file mode 100644 index 00000000..3a2c2228 --- /dev/null +++ b/precise/rsted/src/etc/init/rsted.conf @@ -0,0 +1,18 @@ +# Rsted upstart +# this script will start/stop Rsted +description "Rsted Server" +version "1.0" +author "Valentin Lab" + +start on started networking +stop on runlevel [!2345] + +env LOG_FILE=/var/log/rsted.log +env USER=rsted + + +script + chdir /opt/apps/rsted + exec sudo -u "$USER" /srv/virtualenv/default/bin/python ./application.py >> "$LOG_FILE" 2>&1 +end script + diff --git a/precise/rsted/src/etc/logrotate.d/rsted b/precise/rsted/src/etc/logrotate.d/rsted new file mode 100644 index 00000000..9d3e5cc7 --- /dev/null +++ b/precise/rsted/src/etc/logrotate.d/rsted @@ -0,0 +1,13 @@ +/var/log/rsted.log +{ + rotate 4 + weekly + missingok + notifempty + compress + delaycompress + sharedscripts + postrotate + restart rsted >/dev/null 2>&1 || true + endscript +} diff --git a/precise/rsted/src/etc/rsted/settings.py b/precise/rsted/src/etc/rsted/settings.py new file mode 100644 index 00000000..270b5ab7 --- /dev/null +++ b/precise/rsted/src/etc/rsted/settings.py @@ -0,0 +1,14 @@ +# configuration +DEBUG = True + +PYTHON_PATH='/srv/virtualenv/default/bin/python' +#RUN_AS='rsted' +RUN_PATH = '/var/run/rsted' +PID_FILE = 'fastcgi.pid' +SOCKET_FILE = 'rsted.sock' +FCGI_UMASK = '000' # you can override this in settings_local.py if you wish + +HOST = "0.0.0.0" ## Listen IP + ## 0.0.0.0 is open to everyone, + ## 127.0.0.1 is localhost only. +PORT = 5000