Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
9e3a6c6c
Commit
9e3a6c6c
authored
12 years ago
by
Christophe Simonis
Browse files
Options
Downloads
Patches
Plain Diff
[FIX] win32 service: configure service via sc.exe
bzr revid: chs@openerp.com-20121130113828-abweveb1ryzptvhf
parent
5ec2748e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
win32/OpenERPServerService.py
+22
-19
22 additions, 19 deletions
win32/OpenERPServerService.py
with
22 additions
and
19 deletions
win32/OpenERPServerService.py
+
22
−
19
View file @
9e3a6c6c
...
...
@@ -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__
'
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment