diff --git a/src/core/sat_main.py b/src/core/sat_main.py index 0f510d3b..267a8b8e 100644 --- a/src/core/sat_main.py +++ b/src/core/sat_main.py @@ -19,6 +19,8 @@ from sat.core.i18n import _, D_, languageSwitch from twisted.application import service +from twisted.internet import glib2reactor +glib2reactor.install() from twisted.internet import defer from twisted.words.protocols.jabber import jid from twisted.words.xish import domish diff --git a/src/sat.sh b/src/sat.sh index 5849c431..f9a56355 100755 --- a/src/sat.sh +++ b/src/sat.sh @@ -45,7 +45,6 @@ except: env=[] env.append("PID_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),'')) env.append("LOG_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'log_dir')),'')) - env.append("APP_NAME='%s'" % C.APP_NAME) env.append("APP_NAME_FILE='%s'" % C.APP_NAME_FILE) print ";".join(env) @@ -69,11 +68,9 @@ if [ $# -eq 1 ];then fi fi -MAIN_OPTIONS="-${DAEMON}oy" -TAP_PATH="./" -TAP_FILE="$APP_NAME_FILE.tac" +MAIN_OPTIONS="-${DAEMON}o" -#Don't change the next line +#Don't change the next lines AUTO_OPTIONS="" ADDITIONAL_OPTIONS="--pidfile $PID_FILE --logfile $LOG_FILE $AUTO_OPTIONS $DEBUG" @@ -82,4 +79,4 @@ if [ ! -d $log_dir ] ; then mkdir $log_dir fi -twistd $MAIN_OPTIONS $TAP_PATH$TAP_FILE $ADDITIONAL_OPTIONS +twistd $MAIN_OPTIONS $ADDITIONAL_OPTIONS $APP_NAME_FILE diff --git a/src/sat.tac b/src/twisted/plugins/sat_plugin.py similarity index 73% rename from src/sat.tac rename to src/twisted/plugins/sat_plugin.py index e842772b..a061a849 100644 --- a/src/sat.tac +++ b/src/twisted/plugins/sat_plugin.py @@ -28,9 +28,10 @@ if defer.Deferred.debug: except ImportError: pass -from twisted.application import service -from twisted.internet import glib2reactor -glib2reactor.install() +from zope.interface import implements +from twisted.python import usage +from twisted.plugin import IPlugin +from twisted.application.service import IServiceMaker # XXX: We need to configure logs before any log method is used, so here is the best place. from sat.core.constants import Const as C @@ -39,8 +40,22 @@ log_config.satConfigure(C.LOG_BACKEND_TWISTED) # XXX: SAT must be imported after log configuration, because it write stuff to logs from sat.core.sat_main import SAT +from sat.core.i18n import _ -application = service.Application('SàT') -service = SAT() -service.setServiceParent(application) +class Options(usage.Options): + optParameters = [] + + +class SatMaker(object): + implements(IServiceMaker, IPlugin) + + tapname = C.APP_NAME_FILE + description = _(u"%s XMPP client backend") % C.APP_NAME_FULL + options = Options + + def makeService(self, options): + return SAT() + + +serviceMaker = SatMaker()