當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。