diff options
| author | Christophe Simonis <chs@openerp.com> | 2012-11-30 12:38:28 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@openerp.com> | 2012-11-30 12:38:28 +0100 |
| commit | 9e3a6c6cc3dd2233b82bebc79acf3f63cfd2a433 (patch) | |
| tree | e6535a49c20e7907480bab5e1c21bdd1a4d12c13 | |
| parent | 5ec2748e04c0377edbd864ab662bd717c56d0363 (diff) | |
[FIX] win32 service: configure service via sc.exe
bzr revid: chs@openerp.com-20121130113828-abweveb1ryzptvhf
| -rw-r--r-- | win32/OpenERPServerService.py | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/win32/OpenERPServerService.py b/win32/OpenERPServerService.py index c529b582ba4..3f86c40aa4b 100644 --- a/win32/OpenERPServerService.py +++ b/win32/OpenERPServerService.py @@ -74,26 +74,29 @@ class OpenERPServerService(win32serviceutil.ServiceFramework): def option_handler(opts): # configure the service to auto restart on failures... service_name = OpenERPServerService._svc_name + restart_msg = "Restarting %s" % (OpenERPServerService._svc_display_name_,) - hscm = win32service.OpenSCManager(None, None, win32service.SC_MANAGER_ALL_ACCESS) - try: - hs = win32serviceutil.SmartOpenService(hscm, service_name, win32service.SERVICE_ALL_ACCESS) - try: - service_failure_actions = { - 'ResetPeriod': 0, # Time in ms after which to reset the failure count to zero. - 'RebootMsg': u'', # Not using reboot option - 'Command': u'', # Not using run-command option - 'Actions': [ - (win32service.SC_ACTION_RESTART, 10), # action, delay in ms - (win32service.SC_ACTION_RESTART, 10), - (win32service.SC_ACTION_RESTART, 10), - ] - } - win32service.ChangeServiceConfig2(hs, win32service.SERVICE_CONFIG_FAILURE_ACTIONS, service_failure_actions) - finally: - win32service.CloseServiceHandle(hs) - finally: - win32service.CloseServiceHandle(hscm) + subprocess.call('sc failure %s reset= 0 reboot= %r actions= reboot/0/reboot/0/reboot/0' % (service_name, restart_msg)) + + # hscm = win32service.OpenSCManager(None, None, win32service.SC_MANAGER_ALL_ACCESS) + # try: + # hs = win32serviceutil.SmartOpenService(hscm, service_name, win32service.SERVICE_ALL_ACCESS) + # try: + # service_failure_actions = { + # 'ResetPeriod': 0, # Time in ms after which to reset the failure count to zero. + # 'RebootMsg': u'', # Not using reboot option + # 'Command': u'', # Not using run-command option + # 'Actions': [ + # (win32service.SC_ACTION_RESTART, 10), # action, delay in ms + # (win32service.SC_ACTION_RESTART, 10), + # (win32service.SC_ACTION_RESTART, 10), + # ] + # } + # win32service.ChangeServiceConfig2(hs, win32service.SERVICE_CONFIG_FAILURE_ACTIONS, service_failure_actions) + # finally: + # win32service.CloseServiceHandle(hs) + # finally: + # win32service.CloseServiceHandle(hscm) if __name__ == '__main__': |
