def main_for_service(reactor, service):
 service.startService()
 stop = Deferred()
 reactor.addSystemEventTrigger('before', 'shutdown', _chain_stop_result, service, stop)
 return stop

def main_for_service ( reactor , service ) : service . startService ( ) stop = Deferred ( ) reactor . addSystemEventTrigger ( 'before' , 'shutdown' , _chain_stop_result , service , stop ) return stop
start a service and integrate its shutdown with reactor shutdown .