From b27c4c3a89691dd432b1c53cf2a15180c99655e5 Mon Sep 17 00:00:00 2001 From: Ábner Silva de Oliveira Date: Fri, 7 Feb 2014 18:48:57 -0300 Subject: [PATCH] server config templates --- apache/cluster.conf | 5 +++++ apache/virtualhost.conf | 37 +++++++++++++++++++++++++++++++++++++ etc/pairwise-init.d | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ thin.yml | 3 ++- 4 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 apache/cluster.conf create mode 100644 apache/virtualhost.conf create mode 100644 etc/pairwise-init.d diff --git a/apache/cluster.conf b/apache/cluster.conf new file mode 100644 index 0000000..3661768 --- /dev/null +++ b/apache/cluster.conf @@ -0,0 +1,5 @@ +BalancerMember http://127.0.0.1:5030 +BalancerMember http://127.0.0.1:5031 +BalancerMember http://127.0.0.1:5032 +BalancerMember http://127.0.0.1:5033 + diff --git a/apache/virtualhost.conf b/apache/virtualhost.conf new file mode 100644 index 0000000..bb73068 --- /dev/null +++ b/apache/virtualhost.conf @@ -0,0 +1,37 @@ +DocumentRoot "/opt/pairwise-api/public" + + Options FollowSymLinks -Indexes + AllowOverride None + Order Allow,Deny + Allow from all + + +RewriteEngine On + +# Rewrite index to check for static index.html +RewriteRule ^/$ /index.html [QSA] + +# Rewrite to check for Rails cached page +RewriteRule ^([^.]+)$ $1.html [QSA] + +RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f +RewriteRule ^.*$ balancer://pairwise%{REQUEST_URI} [P,QSA,L] + +ErrorDocument 503 /503.html + +ErrorLog /var/log/apache2/pairwise.log +LogLevel warn +CustomLog /var/log/apache2/pairwise.access.log vhost_combined + +# Compress outgoing text content +AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript + +# Add Expires: header +ExpiresActive On +ExpiresByType text/css "access plus 1 month" +ExpiresByType application/javascript "access plus 1 month" +ExpiresByType image/png "access plus 1 month" +ExpiresByType image/gif "access plus 1 month" +ExpiresByType image/jpeg "access plus 1 month" +ExpiresByType image/x-icon "access plus 1 month" + diff --git a/etc/pairwise-init.d b/etc/pairwise-init.d new file mode 100644 index 0000000..90afd5e --- /dev/null +++ b/etc/pairwise-init.d @@ -0,0 +1,97 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: pairwise +# Required-Start: $remote_fs +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Example initscript +# Description: This file should be used to construct scripts to be +# placed in /etc/init.d. +### END INIT INFO + +# Sample init.d script for pairwise. +# +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="Pairwise web platform" +NAME=pairwise +SCRIPTNAME=/etc/init.d/$NAME + +# default values +PAIRWISE_DIR=/opt/pairwise-api/ +PAIRWISE_USER=pairwise + +# Read configuration variable file if it is present +#[ -r /etc/default/$NAME ] && . /etc/default/$NAME + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +if [ -z "$PAIRWISE_DIR" ] || [ -z "$PAIRWISE_USER" ]; then + echo "PAIRWISE_DIR or PAIRWISE_USER not defined, noosfero not being started." + echo "Both variables must be defined in /etc/default/pairwise" + exit 0 +fi + +#if test -x /usr/sbin/pairwise-check-dbconfig ; then +# if ! pairwise-check-dbconfig; then +# echo "Pairwise database access not configured, service disabled." +# exit 0 +# fi +#fi + +###################### + +main_script() { + cd $PAIRWISE_DIR + #if [ "$PAIRWISE_USER" != "$USER" ]; then + # su $PAIRWISE_USER -l -c "./script/production $1" + #else + bundle exec thin -C thin.yml $1 + #fi +} + +#do_setup() { + +#} + +do_start() { + #if ! running; then + #do_setup + # actually start the service + main_script start + #else + # echo 'Pairwise is already running, nothing to do...' + #fi +} + +do_stop() { + #if running; then + main_script stop + #else + # echo 'Pairwise is already stopped, nothing to do...' + #fi +} + +do_restart() { + do_stop + do_start +} + +running(){ + pgrep -f 'thin server (127.0.0.1:5030)' > /dev/null +} + +case "$1" in + start|stop|restart|setup) + do_$1 + ;; + force-reload) + do_restart + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|setup}" >&2 + exit 3 + ;; +esac + diff --git a/thin.yml b/thin.yml index 35c9717..72ff26b 100644 --- a/thin.yml +++ b/thin.yml @@ -8,7 +8,8 @@ log: log/thin.log max_conns: 1024 require: [] -environment: production +environment: production max_persistent_conns: 512 servers: 4 daemonize: true + -- libgit2 0.21.2