def status(args): from ambari_windows_service import AmbariServerService args.exit_message = None statusStr = AmbariServerService.QueryStatus() print "Ambari Server is " + statusStr
def start(options): from ambari_windows_service import AmbariServerService, ctrlHandler status, pid = is_server_runing() if status: err = "Ambari Server is already running." raise FatalException(1, err) AmbariServerService.set_ctrl_c_handler(ctrlHandler) #Run as a normal process. Invoke the ServiceMain directly. childProc = server_process_main(options) childProc.wait() pid_file_path = os.path.join(configDefaults.PID_DIR, PID_NAME) remove_file(pid_file_path)
def is_server_runing(): from ambari_commons.os_windows import SERVICE_STATUS_STARTING, SERVICE_STATUS_RUNNING, SERVICE_STATUS_STOPPING, \ SERVICE_STATUS_STOPPED, SERVICE_STATUS_NOT_INSTALLED from ambari_windows_service import AmbariServerService statusStr = AmbariServerService.QueryStatus() if statusStr in (SERVICE_STATUS_STARTING, SERVICE_STATUS_RUNNING, SERVICE_STATUS_STOPPING): return True, "" elif statusStr == SERVICE_STATUS_STOPPED: return False, SERVICE_STATUS_STOPPED elif statusStr == SERVICE_STATUS_NOT_INSTALLED: return False, SERVICE_STATUS_NOT_INSTALLED else: return False, None
def stop(): from ambari_windows_service import AmbariServerService AmbariServerService.Stop()
def svcstart(): from ambari_windows_service import AmbariServerService AmbariServerService.Start() pass