def postOptions(self):

        # This does not invoke the super implementation.  At the time this
        # method was implemented, all the super method did was *conditionally*
        # set self['no_save'] to True and take the abspath of self['pidfile'].
        # See below for the irrelevance of those operations.

        self._fixConfig()
        self._checkPID()

        S = self.parent.getStore()  # make sure we open it here

        oldstdout = sys.stdout
        oldstderr = sys.stderr

        self._startLogging()
        app.initialLog()

        self.application = application = self._constructApplication()
        self._startApplication()
        app.runReactorWithLogging(self, oldstdout, oldstderr)
        self._removePID()
        app.reportProfile(self['report-profile'],
                          service.IProcess(application).processName)
        log.msg("Server Shut Down.")
示例#2
0
def startTwisted(application,
                 startDir='./',
                 nodaemon=0,
                 logfile=None,
                 rundir='.',
                 appname='tums',
                 pidfile='/var/run/tums.pid'):
    """ A freezable twistd bootstrap layer """
    from twisted.application import service, internet, strports, app
    from twisted.python import log, syslog
    try:
        from twisted.scripts import _twistd_unix as twistd
    except:
        from twisted.scripts import twistd
    config = {
        'profile': None,
        'reactor': None,
        'encrypted': 0,
        'syslog': 0,
        'prefix': appname,
        'report-profile': None,
        'euid': 0,
        'file': 'twistd.tap',
        'originalname': appname,
        'rundir': rundir,
        'logfile': logfile,
        'nodaemon': nodaemon,
        'uid': None,
        'xml': None,
        'chroot': None,
        'no_save': True,
        'quiet': 0,
        'source': None,
        'nothotshot': 0,
        'gid': None,
        'savestats': 0,
        'debug': False,
        'pidfile': pidfile
    }

    twistd.checkPID(config['pidfile'])
    #app.installReactor(config['reactor'])

    config['nodaemon'] = config['nodaemon'] or config['debug']

    oldstdout = sys.stdout
    oldstderr = sys.stderr

    twistd.startLogging(config['logfile'], config['syslog'], config['prefix'],
                        config['nodaemon'])

    app.initialLog()

    twistd.startApplication(config, application)

    app.runReactorWithLogging(config, oldstdout, oldstderr)
    twistd.removePID(config['pidfile'])
    app.reportProfile(config['report-profile'],
                      service.IProcess(application).processName)
    log.msg("Server Shut Down.")
    def postOptions(self):

        # This does not invoke the super implementation.  At the time this
        # method was implemented, all the super method did was *conditionally*
        # set self['no_save'] to True and take the abspath of self['pidfile'].
        # See below for the irrelevance of those operations.

        self._fixConfig()
        self._checkPID()

        S = self.parent.getStore()  # make sure we open it here

        oldstdout = sys.stdout
        oldstderr = sys.stderr

        self._startLogging()
        app.initialLog()

        self.application = application = self._constructApplication()
        self._startApplication()
        app.runReactorWithLogging(self, oldstdout, oldstderr)
        self._removePID()
        app.reportProfile(
            self['report-profile'],
            service.IProcess(application).processName)
        log.msg("Server Shut Down.")
 def preApplication(self):
     """
     Do pre-application-creation setup.
     """
     self.oldstdout = sys.stdout
     self.oldstderr = sys.stderr
     startLogging(self.config['logfile'])
     app.initialLog()
     os.chdir(self.config['rundir'])
示例#5
0
 def preApplication(self):
     """
     Do pre-application-creation setup.
     """
     self.oldstdout = sys.stdout
     self.oldstderr = sys.stderr
     startLogging(self.config['logfile'])
     app.initialLog()
     os.chdir(self.config['rundir'])
示例#6
0
 def preApplication(self):
     """
     Do pre-application-creation setup.
     """
     checkPID(self.config['pidfile'])
     self.config['nodaemon'] = (self.config['nodaemon']
                                or self.config['debug'])
     self.oldstdout = sys.stdout
     self.oldstderr = sys.stderr
     startLogging(self.config['logfile'], self.config['syslog'],
                  self.config['prefix'], self.config['nodaemon'])
     app.initialLog()
 def preApplication(self):
     """
     Do pre-application-creation setup.
     """
     checkPID(self.config['pidfile'])
     self.config['nodaemon'] = (self.config['nodaemon'] 
                                or self.config['debug'])
     self.oldstdout = sys.stdout
     self.oldstderr = sys.stderr
     startLogging(self.config['logfile'], self.config['syslog'],
                  self.config['prefix'], self.config['nodaemon'])
     app.initialLog()
示例#8
0
def runApp(config):
    checkPID(config["pidfile"])
    passphrase = app.getPassphrase(config["encrypted"])
    app.installReactor(config["reactor"])
    config["nodaemon"] = config["nodaemon"] or config["debug"]
    oldstdout = sys.stdout
    oldstderr = sys.stderr
    startLogging(config["logfile"], config["syslog"], config["prefix"], config["nodaemon"])
    app.initialLog()
    application = app.getApplication(config, passphrase)
    startApplication(config, application)
    app.runReactorWithLogging(config, oldstdout, oldstderr)
    removePID(config["pidfile"])
    app.reportProfile(config["report-profile"], service.IProcess(application).processName)
    log.msg("Server Shut Down.")
示例#9
0
def runApp(config):
    passphrase = app.getPassphrase(config['encrypted'])
    app.installReactor(config['reactor'])
    application = app.getApplication(config, passphrase)
    oldstdout = sys.stdout
    oldstderr = sys.stderr
    startLogging(config['logfile'])
    app.initialLog()
    os.chdir(config['rundir'])
    service.IService(application).privilegedStartService()
    app.startApplication(application, not config['no_save'])
    app.startApplication(internet.TimerService(0.1, lambda:None), 0)
    app.runReactorWithLogging(config, oldstdout, oldstderr)
    app.reportProfile(config['report-profile'],
                      service.IProcess(application).processName)
    log.msg("Server Shut Down.")
示例#10
0
def runApp(config):
    passphrase = app.getPassphrase(config['encrypted'])
    app.installReactor(config['reactor'])
    application = app.getApplication(config, passphrase)
    oldstdout = sys.stdout
    oldstderr = sys.stderr
    startLogging(config['logfile'])
    app.initialLog()
    os.chdir(config['rundir'])
    service.IService(application).privilegedStartService()
    app.startApplication(application, not config['no_save'])
    app.startApplication(internet.TimerService(0.1, lambda: None), 0)
    app.runReactorWithLogging(config, oldstdout, oldstderr)
    app.reportProfile(config['report-profile'],
                      service.IProcess(application).processName)
    log.msg("Server Shut Down.")
示例#11
0
def runApp(config):
    checkPID(config['pidfile'])
    passphrase = app.getPassphrase(config['encrypted'])
    app.installReactor(config['reactor'])
    config['nodaemon'] = config['nodaemon'] or config['debug']
    oldstdout = sys.stdout
    oldstderr = sys.stderr
    startLogging(config['logfile'], config['syslog'], config['prefix'],
                 config['nodaemon'])
    app.initialLog()
    application = app.getApplication(config, passphrase)
    startApplication(config, application)
    app.runReactorWithLogging(config, oldstdout, oldstderr)
    removePID(config['pidfile'])
    app.reportProfile(config['report-profile'],
                      service.IProcess(application).processName)
    log.msg("Server Shut Down.")