view src/sat.sh @ 371:3ea41a199b36

bridge refactoring: categories are now core and plugin instead of communication and request
author Goffi <goffi@goffi.org>
date Wed, 06 Jul 2011 01:04:24 +0200
parents e83d0c21d64d
children ac568832a71a
line wrap: on
line source

#!/bin/sh

#if there is one argument which is "stop", then we kill SàT
DEBUG=""
if [ $# -eq 1 ];then
	if [ $1 = "stop" ];then
		echo "Terminating Salut à Toi"
		pkill -f "twistd.*/sat.tac"
		exit 0
	fi
	if [ $1 = "debug" ];then
		echo "Launching SàT in debug mode"
		DEBUG="--debug"
	fi
fi

NAME='sat'

#We use python to parse config files
eval `python<<PYTHONEND
from ConfigParser import SafeConfigParser
from os.path import expanduser, join

config = SafeConfigParser(defaults={'local_dir':'~/.sat',
									'pid_dir':'/tmp',
									'log_dir':'%(local_dir)s'})
try:
	config.read(map(expanduser, ['/etc/sat.conf', '~/sat.conf', '~/.sat.conf', 'sat.conf', '.sat.conf']))
except:
	print ("Can't read main config !")
print "LOCAL_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'local_dir')),'')
print "PID_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),'')
print "LOG_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),'')
PYTHONEND
`
PID_FILE="$PID_DIR$NAME.pid"
LOG_FILE="$LOCAL_DIR$NAME.log"
DAEMON="n"
MAIN_OPTIONS="-${DAEMON}oy"
TAP_PATH="./"
TAP_FILE="$NAME.tac"

#Don't change the next line
AUTO_OPTIONS=""
ADDITIONAL_OPTIONS="--pidfile $PID_FILE --logfile $LOG_FILE $AUTO_OPTIONS $DEBUG"

log_dir=`dirname "$LOG_FILE"`
if [ ! -d $log_dir ] ; then
	mkdir $log_dir
fi

twistd $MAIN_OPTIONS $TAP_PATH$TAP_FILE $ADDITIONAL_OPTIONS