I am trying to control the behavior of a service with regards to failure
handling as described here:
http://blogs.msdn.com/b/jcalev/archive/2008/01/10/some-tricks-with-service-restart-logic.aspx

I have done some reading and have the following snippet of code that I think
is going in the right direction. However I don't know how to create the
action list. I suspect that it should be an array of unsigned long ints,
but... ???


        hscm =
win32service.OpenSCManager(None,None,win32service.SC_MANAGER_ALL_ACCESS)

        try:
            hs = SmartOpenService(hscm, cls._svc_name_,
win32service.SERVICE_ALL_ACCESS)
            try:
                # What's the pythonic way to create these???
                action1 = Action()
                action1.Type = win32service.SC_ACTION_RESTART
                action1.Delay = 600  # 10 minutes?

                action2 = Action()
                action2.Type = win32service.SC_ACTION_RESTART
                action2.Delay = 600

                action3 = Action()
                action3.Type = win32service.SC_ACTION_RESTART
                action3.Delay = 600

                win32service.ChangeServiceConfig2(
                    hs,
                    win32service.SERVICE_CONFIG_FAILURE_ACTIONS,
                    [action1,action2,action3]  # again, this isn't probably
right, but... ?
                )
            finally:
                win32service.CloseServiceHandle(hs)
        finally:
            win32service.CloseServiceHandle(hscm)

Can anyone help please?

Andrew
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to