From: Jason Hiltz-L. <ja...@jy...> - 2007-11-15 17:00:07
|
David Bolen <db3l.net <at> gmail.com> writes: > Ah, I may have misinterpreted the type of error you were referring to. > I assumed it was probably the StartServiceCtrlDispatcher error and not > a Windows error. If the service is failing to identify itself to > Windows as it starts, then there's a good possibility that it's > generating an exception at some point during initialization. > > In your posted minimal example, I found that you have an unqualified > CreateEvent call (that should be win32event.CreateEvent) in line 4 of > __init__. Note that you won't necessarily notice this in the "python > MyService.py start" case since by default the win32 wrapper doesn't > actually wait for the service to start, nor report failures. Good catch :-) I fixed it. > If I fix that, then your posted myservice seems to work fine for me, > both as a script and built as an executable with py2exe. This was > with Python 2.5.1, and py2exe 0.6.6 Not for me. Sigh. > First, verify that your service really does run as a normal script, since > that's less effort to debug. You can use a "debug" command line option > to start up the service with normal stdout/stderr. It does. Running with "debug" spits out everything with no issues. > Next, try checking your event log after failing to start the service > when built as binary. If you're lucky, the exception information will > be logged there with the event indicating that the service failed to > start. No luck there. > If not, I just noticed that py2exe 0.6.6 supports selecting command > line parsing styles, and you can switch it to using the same pywin32 > command line handler as when the script runs directly. This buys you > the same "debug" option that runs with stdout/stderr connected. You > want a service argument to your setup() call like: > > setup(..., > service = [{'modules': ['myservice'], > 'cmdline_style': 'pywin32'}], > ...) > > Then you'll be able to run "service_executable debug" manually, and > hopefully you'll see the error when it tries to start up. This is what triggered the solution to the issue. I looked at my setup.py again and I was telling py2exe to build it as a *console* app!!! No kidding it worked fine everywhere except in service mode! After modifying my setup to use service and point it to the right module, everything appears to work like a charm. I feel like such a bonehead... Thanks for all the help and great explanations/suggestions David. If you hadn't been so thorough, I probably just would have given up on this whole thing out of frustration. Thanks again! Cheers, Jason |