def _pscOK(self, startupInfo): """ Now start the service. If OK, message the PSC accordingly; if not, let the PSC know we've failed and why, then initiate closedown. """ self.name = startupInfo['serviceName'] self.publishedName = startupInfo['publishedName'] self.servicepath = startupInfo['servicePath'] logging.closeHandlers() logToConsole = False if startupInfo['logdir'] == None: logToConsole = True logging.initLogging(rootLoggerName='WORKER: %s' % self.name, logLevel=getattr(logging, startupInfo['loglevel']), logdir=startupInfo['logdir'], logfile="worker_%s.log" % self.name, logToConsole=logToConsole) logging.setAdditionalLoggers(self) self.logger = logging.getLogger() # add any sevice directories to sys.path if not already there for sd in self.servicepath: if sd not in sys.path: sys.path.append(sd) self.loadService(startupInfo['runtimeConfig']) try: self.pscReference = startupInfo['pwa'] except Exception,ex: self.logger.exception('[1]')
def start(pc): """ Start a PSC. By default the first step is to daemonise, either by a double fork (on a POSIX system) or by re-spawning the process (on Windows) to detach from the console; this can be over-ridden by specifying --nodetach on the command line. The kernel is then started. This creates worker processes as required via the subprocess module. """ if not pc.nodetach: makeDaemon() logging.initLogging(rootLoggerName='PSC', logLevel=getattr(logging, pc.loglevel), logdir=pc.logdir, logfile='psc.log', logToConsole=pc.nodetach) logging.getLogger().info("Kernel starting; pid = %d" % os.getpid()) kernel = PelotonKernel(pc) logging.setAdditionalLoggers(kernel) ex = kernel.start() return ex