当前位置: 首页>>代码示例>>Python>>正文


Python servicemanager.PYS_SERVICE_STARTED属性代码示例

本文整理汇总了Python中servicemanager.PYS_SERVICE_STARTED属性的典型用法代码示例。如果您正苦于以下问题:Python servicemanager.PYS_SERVICE_STARTED属性的具体用法?Python servicemanager.PYS_SERVICE_STARTED怎么用?Python servicemanager.PYS_SERVICE_STARTED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在servicemanager的用法示例。


在下文中一共展示了servicemanager.PYS_SERVICE_STARTED属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SvcDoRun

# 需要导入模块: import servicemanager [as 别名]
# 或者: from servicemanager import PYS_SERVICE_STARTED [as 别名]
def SvcDoRun(self):
        servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
                              servicemanager.PYS_SERVICE_STARTED,
                              (self._svc_name_, ''))
        self.isAlive = True
        # Create new threads
        self.main() 
开发者ID:AutohomeRadar,项目名称:Windows-Agent,代码行数:9,代码来源:agent.py

示例2: SvcDoRun

# 需要导入模块: import servicemanager [as 别名]
# 或者: from servicemanager import PYS_SERVICE_STARTED [as 别名]
def SvcDoRun(self):
        # Write an event log record - in debug mode we will also
        # see this message printed.
        servicemanager.LogMsg(
                servicemanager.EVENTLOG_INFORMATION_TYPE,
                servicemanager.PYS_SERVICE_STARTED,
                (self._svc_name_, '')
                )

        num_connections = 0
        while 1:
            pipeHandle = CreateNamedPipe("\\\\.\\pipe\\PyPipeTest",
                    PIPE_ACCESS_DUPLEX| FILE_FLAG_OVERLAPPED,
                    PIPE_TYPE_MESSAGE | PIPE_READMODE_BYTE,
                    PIPE_UNLIMITED_INSTANCES,       # max instances
                    0, 0, 6000,
                    self.CreatePipeSecurityObject())
            try:
                hr = ConnectNamedPipe(pipeHandle, self.overlapped)
            except error, details:
                print "Error connecting pipe!", details
                CloseHandle(pipeHandle)
                break
            if hr==winerror.ERROR_PIPE_CONNECTED:
                # Client is already connected - signal event
                SetEvent(self.overlapped.hEvent)
            rc = WaitForMultipleObjects((self.hWaitStop, self.overlapped.hEvent), 0, INFINITE)
            if rc==WAIT_OBJECT_0:
                # Stop event
                break
            else:
                # Pipe event - spawn thread to deal with it.
                thread.start_new_thread(self.ProcessClient, (pipeHandle,))
                num_connections = num_connections + 1

        # Sleep to ensure that any new threads are in the list, and then
        # wait for all current threads to finish.
        # What is a better way? 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:40,代码来源:pipeTestService.py

示例3: SvcDoRun

# 需要导入模块: import servicemanager [as 别名]
# 或者: from servicemanager import PYS_SERVICE_STARTED [as 别名]
def SvcDoRun(self):
        '''
        Called when the service is asked to start
        '''
        self.start()
        servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
                              servicemanager.PYS_SERVICE_STARTED,
                              (self._svc_name_, ''))
        self.main() 
开发者ID:frappe,项目名称:biometric-attendance-sync-tool,代码行数:11,代码来源:SMWinservice.py

示例4: SvcDoRun

# 需要导入模块: import servicemanager [as 别名]
# 或者: from servicemanager import PYS_SERVICE_STARTED [as 别名]
def SvcDoRun(self):
        servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
                              servicemanager.PYS_SERVICE_STARTED,
                              (self._svc_name_, ''))
        servicemanager.LogInfoMsg('ceajenkins before main')
        try:
            self.main()
        except:
            servicemanager.LogErrorMsg(traceback.format_exc())
            sys.exit(-1)
        servicemanager.LogInfoMsg('normal exit') 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:13,代码来源:ceajenkins.py

示例5: SvcDoRun

# 需要导入模块: import servicemanager [as 别名]
# 或者: from servicemanager import PYS_SERVICE_STARTED [as 别名]
def SvcDoRun(self):
        # Redirect stdout and stderr to prevent "IOError: [Errno 9]
        # Bad file descriptor". Windows services don't have functional
        # output streams.
        sys.stdout = sys.stderr = open("nul", "w")

        # Write a 'started' event to the event log...
        win32evtlogutil.ReportEvent(
            self._svc_display_name_,
            servicemanager.PYS_SERVICE_STARTED,
            0,  # category
            servicemanager.EVENTLOG_INFORMATION_TYPE,
            (self._svc_name_, ""),
        )
        print("Begin: %s" % self._svc_display_name_)

        hostport = ":8888"
        print("Starting py.execnet SocketServer on %s" % hostport)
        serversock = socketserver.bind_and_listen(hostport)
        thread = threading.Thread(
            target=socketserver.startserver, args=(serversock,), kwargs={"loop": True}
        )
        thread.setDaemon(True)
        thread.start()

        # wait to be stopped or self.WAIT_TIME to pass
        while True:
            result = win32event.WaitForSingleObject(self.hWaitStop, self.WAIT_TIME)
            if result == win32event.WAIT_OBJECT_0:
                break

        # write a 'stopped' event to the event log.
        win32evtlogutil.ReportEvent(
            self._svc_display_name_,
            servicemanager.PYS_SERVICE_STOPPED,
            0,  # category
            servicemanager.EVENTLOG_INFORMATION_TYPE,
            (self._svc_name_, ""),
        )
        print("End: %s" % appname) 
开发者ID:pytest-dev,项目名称:execnet,代码行数:42,代码来源:socketserverservice.py

示例6: SvcDoRun

# 需要导入模块: import servicemanager [as 别名]
# 或者: from servicemanager import PYS_SERVICE_STARTED [as 别名]
def SvcDoRun(self):

        # __file__ == 'service_win32.py'
        exe_dir = os.path.dirname(os.path.dirname(__file__))
        os.chdir(exe_dir)

        win32evtlogutil.ReportEvent(
            self._svc_name_,
            servicemanager.PYS_SERVICE_STARTED,
            0,
            servicemanager.EVENTLOG_INFORMATION_TYPE,
            (self._svc_name_, ''))

        config_file = os.path.join(exe_dir, 'agent.conf')
        config = Config(config_file)

        supervisor = Supervisor(config)
        win32evtlogutil.ReportEvent(
            self._svc_name_,
            servicemanager.PYS_SERVICE_STOPPED,
            0,
            servicemanager.EVENTLOG_INFORMATION_TYPE,
            (self._svc_name_, ''))

        thread = Thread(target=supervisor.start)
        thread.daemon = True
        thread.start()

        while True:
            rc = win32event.WaitForSingleObject(
                self.hWaitStop, win32event.INFINITE)
            if rc == win32event.WAIT_OBJECT_0:
                win32evtlogutil.ReportEvent(
                    self._svc_name_,
                    servicemanager.PYS_SERVICE_STOPPED,
                    0,
                    servicemanager.EVENTLOG_INFORMATION_TYPE,
                    (self._svc_name_, ''))
                break 
开发者ID:postgrespro,项目名称:mamonsu,代码行数:41,代码来源:service_win32.py

示例7: SvcDoRun

# 需要导入模块: import servicemanager [as 别名]
# 或者: from servicemanager import PYS_SERVICE_STARTED [as 别名]
def SvcDoRun(self):
        try:
            LOG('SvcDoRun')
            import servicemanager
            servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, ''))
            servicemanager.LogInfoMsg("OpsBro Start")

            # Set as english
            locale.setlocale(locale.LC_ALL, 'English_Australia.1252')
            
            # under service, stdout and stderr are not available
            # TODO: enable debug mode?
            self.destroy_stdout_stderr()
            LOG('BEFORE CLI')
            # simulate CLI startup with config parsing
            from opsbro.log import cprint, logger, is_tty
            from opsbro.cli import CLICommander, save_current_binary
            from opsbro.yamlmgr import yamler
            
            with open('c:\\opsbro\\etc\\agent.yml', 'r') as f:
                buf = f.read()
                CONFIG = yamler.loads(buf)

            LOG('CONF LOADED')
            
            # Load config
            CLI = CLICommander(CONFIG, None)
            
            LOG('CLI LOADED')
            l = Launcher(cfg_dir='c:\\opsbro\\etc')
            LOG('LAUNCHER created, launching init & main')
            # Note: before launch the start/main, we need to start a stopper thread (on the main process)
            l.do_daemon_init_and_start(is_daemon=False, before_start_callback=self._before_start_callback)
            LOG('LAUNCHER init')
            # called when we're being shut down
        except Exception:
            err = traceback.format_exc()
            LOG('CRASH: %s' % err)
            logger_crash.error(err)
            raise 
开发者ID:naparuba,项目名称:opsbro,代码行数:42,代码来源:windows_service.py

示例8: SvcDoRun

# 需要导入模块: import servicemanager [as 别名]
# 或者: from servicemanager import PYS_SERVICE_STARTED [as 别名]
def SvcDoRun(self):
            servicemanager.LogMsg(
                servicemanager.EVENTLOG_INFORMATION_TYPE,
                servicemanager.PYS_SERVICE_STARTED,
                (self._svc_name_, '')
            )
            self.main() 
开发者ID:target,项目名称:grease,代码行数:9,代码来源:DaemonCmd.py


注:本文中的servicemanager.PYS_SERVICE_STARTED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。