#NEWLINE# def StartDaemon( self ) : #NEWLINE# #INDENT# 'Spins off a process that runs as a daemon.' #NEWLINE# pid = os . fork ( ) #NEWLINE# logging . debug ( 'Forked new process, pid= {0}' . format ( pid ) ) #NEWLINE# if ( pid == 0 ) : #NEWLINE# #INDENT# os . setsid ( ) #NEWLINE# pid = os . fork ( ) #NEWLINE# if ( pid == 0 ) : #NEWLINE# #INDENT# os . chdir ( '/' ) #NEWLINE# os . umask ( 0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# os . _exit ( 0 ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# os . _exit ( 0 ) #NEWLINE# #UNINDENT# pidf = open ( pidf . pidfile , 'w' ) #NEWLINE# pidf . write ( str ( os . getpid ( ) ) ) #NEWLINE# pidf . close ( ) #NEWLINE# logging . debug ( 'Sending signal SIGTERM to shutdown daemon' ) #NEWLINE# signal . signal ( signal . SIGTERM , self . ShutdownDaemon ) #NEWLINE# self . accounts_manager . Main ( )