~certify-web-dev/twisted/certify-trunk

« back to all changes in this revision

Viewing changes to twisted/scripts/_twistw.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-01-17 14:52:35 UTC
  • mfrom: (1.1.5 upstream) (2.1.2 etch)
  • Revision ID: james.westby@ubuntu.com-20070117145235-btmig6qfmqfen0om
Tags: 2.5.0-0ubuntu1
New upstream version, compatible with python2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
    log.startLogging(logFile)
30
30
    sys.stdout.flush()
31
31
 
32
 
def runApp(config):
33
 
    passphrase = app.getPassphrase(config['encrypted'])
34
 
    app.installReactor(config['reactor'])
35
 
    application = app.getApplication(config, passphrase)
36
 
    oldstdout = sys.stdout
37
 
    oldstderr = sys.stderr
38
 
    startLogging(config['logfile'])
39
 
    app.initialLog()
40
 
    os.chdir(config['rundir'])
41
 
    service.IService(application).privilegedStartService()
42
 
    app.startApplication(application, not config['no_save'])
43
 
    app.startApplication(internet.TimerService(0.1, lambda:None), 0)
44
 
    app.runReactorWithLogging(config, oldstdout, oldstderr)
45
 
    app.reportProfile(config['report-profile'],
46
 
                      service.IProcess(application).processName)
47
 
    log.msg("Server Shut Down.")
48
 
 
49
 
 
50
 
def run():
51
 
    app.run(runApp, ServerOptions)
 
32
 
 
33
 
 
34
class WindowsApplicationRunner(app.ApplicationRunner):
 
35
    """
 
36
    An ApplicationRunner which avoids unix-specific things. No
 
37
    forking, no PID files, no privileges.
 
38
    """
 
39
    def preApplication(self):
 
40
        """
 
41
        Do pre-application-creation setup.
 
42
        """
 
43
        self.oldstdout = sys.stdout
 
44
        self.oldstderr = sys.stderr
 
45
        startLogging(self.config['logfile'])
 
46
        app.initialLog()
 
47
        os.chdir(self.config['rundir'])
 
48
 
 
49
 
 
50
    def postApplication(self):
 
51
        """
 
52
        Start the application and run the reactor.
 
53
        """
 
54
        service.IService(self.application).privilegedStartService()
 
55
        app.startApplication(self.application, not self.config['no_save'])
 
56
        app.startApplication(internet.TimerService(0.1, lambda:None), 0)
 
57
        app.runReactorWithLogging(self.config, self.oldstdout, self.oldstderr)
 
58
        app.reportProfile(self.config['report-profile'],
 
59
                          service.IProcess(self.application).processName)
 
60
        log.msg("Server Shut Down.")
 
61