Skip to content

Commit

Permalink
adding helper scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
extremeunix committed Jun 12, 2014
1 parent 3936903 commit 1c557b6
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
31 changes: 31 additions & 0 deletions bin/cito-plugin-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
set -e
export DJANGO_SETTINGS_MODULE='cito_plugin_server.settings.production'

LOGFILE=/opt/cito_plugin_server/logs/cito-webapp.log
LOGDIR=$(dirname $LOGFILE)
NUM_WORKERS=2
PORT=9000
BIND_IP=0.0.0.0:$PORT

# user/group to run as
#USER=www-data
#GROUP=www-data

if [ $USER != "www-data" ]; then
echo "!!!WARNING!! You should probably run this script with www-data"
GROUP=$USER
fi


# switch to project dir, activate virtual environment
cd /opt/cito_plugin_server
source /opt/virtualenvs/citopluginvenv/bin/activate

test -d $LOGDIR || mkdir -p $LOGDIR

python manage.py run_gunicorn \
--workers $NUM_WORKERS \
--user=$USER --group=$GROUP \
--log-level=debug --log-file=$LOGFILE 2>>$LOGFILE --bind $BIND_IP

18 changes: 18 additions & 0 deletions bin/create-django-secret.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env python
"""Copyright 2014 Cyrus Dasadia
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License."""
import random

secret_sauce = "".join([random.SystemRandom().choice("abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)") for i in range(50)])
print "\n# Copy this to cito_plugin_server/settings/secret_key.py\nSECRET_KEY = '%s'\n" % secret_sauce
13 changes: 13 additions & 0 deletions bin/upstart/cito-plugin-server.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Upstart for cito plugin server webapp
description "CitoEngine PluginServer Webapp start/stop script"
version "1.0"
author "Cyrus Dasadia [[email protected]]"

start on runlevel [2345]
stop on runlevel [016]

respawn
respawn limit 10 5

exec /opt/cito_plugin_server/bin/cito-plugin-server.sh

15 changes: 15 additions & 0 deletions bin/upstart/configure-upstart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# Simple script to confgiure upstart
#

set -e

if [ $USER != 'root' ];then
echo "You need to run this script as root"
exit 1
fi

echo "Configuring cito-plugin-server.."
ln -sf /lib/init/upstart-job /etc/init.d/cito-plugin-server
cp /opt/cito/bin/upstart/cito-plugin-server.conf /etc/init/
/usr/sbin/update-rc.d cito-plugin-server defaults

0 comments on commit 1c557b6

Please sign in to comment.