def start(self): try: runtime.logger.info('Server starting...') # start services runtime.logger.info('Starting services...') services.start() except Exception as e: runtime.logger.error(e, *(), **{'exc_info': True}) # stop services services.stop() raise e # start asyn thread self._asyn_thread = Thread(target=self._async_loop, name='Asyncore thread') self._asyn_thread.start() self.running = True # record process id pidfile = open(PID_FILE, "w") if os.name == 'posix': pidfile.write(str(os.getpgid(os.getpid()))) else: pidfile.write(str(os.getpid())) pidfile.close() runtime.logger.info('Porcupine Server started succesfully') print('Porcupine Server v%s' % __version__) python_version = 'Python %s' % sys.version runtime.logger.info(python_version) print(python_version) print('''Porcupine comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions; See COPYING for more details.''')
def shutdown(self, arg1=None, arg2=None): print('Initiating shutdown...') runtime.logger.info('Initiating shutdown...') self.running = False # stop services runtime.logger.info('Stopping services...') services.stop() # join asyn thread asyncore.close_all() self._asyn_thread.join()