예제 #1
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import tasbot, sys
from tasbot.customlog import Log

if __name__ == "__main__":
    configfile = "Main.conf"
    config = tasbot.ParseConfig.Config(configfile)
    Log.Init(config['logfile'], 'info', True)

    r = False
    for arg in sys.argv:
        if arg.strip() == "-r":
            r = True
            Log.Notice("Registering account")
    pidfile = config['pidfile']
    print 'using pidfile %s' % pidfile
    inst = tasbot.DefaultApp(configfile, pidfile, r, True)
    if bool(config.GetSingleOption('debug', False)):
        inst.run()  #exec in fg
    else:
        inst.start()
예제 #2
0
    def Shutdown(self):
        try:
            for name, host in self.Hosts.iteritems():
                host.Shutdown()
            self.Master.Shutdown()
            sys.exit(0)
        except:
            sys.exit(-1)

    def run(self):
        self.Start()
        while 1:
            try:
                time.sleep(1)
            except SystemExit:
                self.Shutdown()
                return
            except KeyboardInterrupt:
                #error("SIGINT, Exiting")
                self.Shutdown()
                return
            except Exception, e:
                #error("parsing command line")
                Log.Except(e)


if __name__ == '__main__':
    Log.Init('server.log', 'info', True)
    S = Server()
    S.run()