Exemple #1
0
    def SvcDoRun(self):
        config_file = os.path.join(System.get_default_config_dir(),
                                   "slaveserver.conf")
        if not Config.read(ConfigReader.process(None)):
            return

        if not Config.is_valid():
            return

        Win32Logger.initialize("OVD", Config.log_level, Config.log_file)

        try:
            ServerCheckup.check()
        except:
            Logger.exception("Server checkup")
            return

        slave = SlaveServer(Communication)

        if not slave.load_roles():
            return

        if not slave.init():
            Logger.error("Unable to initialize SlaveServer")
            slave.stop()
            return

        inited = False
        rc = win32event.WAIT_TIMEOUT
        while rc == win32event.WAIT_TIMEOUT:
            if not inited:
                ret = slave.push_production()
                if ret:
                    inited = True
                    Logger.info("SlaveServer started")
                else:
                    Logger.warn(
                        "Session Manager not connected. Sleeping for a while ..."
                    )

            if inited:
                slave.loop_procedure()

            rc = win32event.WaitForSingleObject(self.hWaitStop, 30 * 1000)

        if not slave.stopped:
            slave.stop()

        Logger.info("SlaveServer stopped")
	def SvcDoRun(self):
		config_file = os.path.join(System.get_default_config_dir(), "slaveserver.conf")
		if not Config.read(ConfigReader.process(None)):
			return
		
		if not Config.is_valid():
			return
		
		Win32Logger.initialize("OVD", Config.log_level, Config.log_file)
		
		try:
			ServerCheckup.check()
		except:
			Logger.exception("Server checkup")
			return
		
		slave = SlaveServer(Communication)
		
		if not slave.load_roles():
			return
		
		if not slave.init():
			Logger.error("Unable to initialize SlaveServer")
			slave.stop()
			return
		
		inited = False
		rc = win32event.WAIT_TIMEOUT
		while rc == win32event.WAIT_TIMEOUT:
			if not inited:
				ret = slave.push_production()
				if ret:
					inited = True
					Logger.info("SlaveServer started")
				else:
					Logger.warn("Session Manager not connected. Sleeping for a while ...")
			
			if inited:
				slave.loop_procedure()
			
			rc = win32event.WaitForSingleObject(self.hWaitStop, 30 * 1000)
		
		if not slave.stopped:
			slave.stop()
		
		Logger.info("SlaveServer stopped")
            config_file = a
        elif o in ("-d", "--daemonize"):
            daemonize = True
        elif o in ("-h", "--help"):
            usage()
            sys.exit()
        elif o in ("-p", "--pid-file"):
            pid_file = a

    if len(args) > 0:
        print >> sys.stderr, "Invalid argument '%s'" % (args[0])
        usage()
        sys.exit(2)

    try:
        ServerCheckup.check()
    except Exception, e:
        print >> sys.stderr, "Server checkup error:", e
        sys.exit(2)

    if daemonize:
        q = multiprocessing.Queue()
        p = multiprocessing.Process(target=main,
                                    args=(q, config_file, pid_file))
        p.start()

        # hack: do not join children process at exit
        multiprocessing.process._current_process._children.remove(p)
        code, msg = q.get()
    else:
        code, msg = main(None, config_file, pid_file)
			config_file = a
		elif o in ("-d", "--daemonize"):
			daemonize = True
		elif o in ("-h", "--help"):
			usage()
			sys.exit()
		elif o in ("-p", "--pid-file"):
			pid_file = a
	
	if len(args) > 0:
		print >> sys.stderr, "Invalid argument '%s'"%(args[0])
		usage()
		sys.exit(2)
	
	try:
		ServerCheckup.check()
	except Exception, e:
		print >> sys.stderr, "Server checkup error:", e
		sys.exit(2)
	
	if daemonize:
		q = multiprocessing.Queue()
		p = multiprocessing.Process(target=main, args=(q, config_file, pid_file))
		p.start()
		
		# hack: do not join children process at exit
		multiprocessing.process._current_process._children.remove(p)
		code, msg = q.get()
	else:
		code, msg = main(None, config_file, pid_file)