def main(): module = AnsibleModule( argument_spec = dict( config=dict(required=True, type='path'), state=dict(default='present', choices=['present', 'absent']) ), supports_check_mode=True ) configfile = module.params['config'] options = ServerOptions() options.configfile = configfile options.progname = 'supervisord' try: options.process_config(do_usage=True) except ValueError as e: module.fail_json(msg = e.message.message) options.realize(args=[], progname='supervisord') server = xmlrpclib.ServerProxy( 'http://127.0.0.1', allow_none=True, transport=SupervisorTransport(serverurl=options.serverurl)) try: server.supervisor.getPID() state = 'present' except socket.error: state = 'absent' desired = module.params['state'] if state == desired: module.exit_json(changed=False) if not module.check_mode: if desired == 'present': module.run_command(["supervisord", "-c", configfile], check_rc=True) elif desired == 'absent': server.supervisor.shutdown() module.exit_json(changed=True)
def main(args=None, test=False): assert os.name == "posix", "This code makes Unix-specific assumptions" # if we hup, restart by making a new Supervisor() first = True while 1: options = ServerOptions() options.realize(args, doc=__doc__) options.first = first options.test = test if options.profile_options: sort_order, callers = options.profile_options profile('go(options)', globals(), locals(), sort_order, callers) else: go(options) if test or (options.mood < SupervisorStates.RESTARTING): break options.close_httpservers() options.close_logger() first = False
def main(args=None, test=False): assert os.name == "posix", "This code makes Unix-specific assumptions" # if we hup, restart by making a new Supervisor() first = True # while 1: if 1: options = ServerOptions() # attribute_value = options.__dict__ # for key,value in attribute_value.items(): # print(key,value) # __doc__ 该文件下 options.realize(args, doc=__doc__) options.first = first options.test = test if options.profile_options: sort_order, callers = options.profile_options profile('go(options)', globals(), locals(), sort_order, callers) else: go(options) options.close_httpservers() options.close_logger() first = False