假设我有一个我写的基于win32serviceutil.ServiceFramework
这样的服务:
class Launcher(win32serviceutil.ServiceFramework):
_svc_name_ = "QueueFolders"
_svc_display_name_ = "Queue Hot Folders"
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
def SvcStop(self):
sys.stopservice = True
def SvcDoRun(self):
# A call to something Main() like here.
QueueFolders()
在此示例中,调用QueueFolders
实例化一个对象,如果已完成正确的配置,该对象应长时间运行。如果不是,它会引发异常,我会在命令提示符下得到这个:
j:\EclipseWorkspace\Queue Folders\dist>net start queuefolders
The Queue Hot Folders service is starting.
The Queue Hot Folders service could not be started.
The service did not report an error.
More help is available by typing NET HELPMSG 3534.
我想知道,我该如何报告这个错误?我知道我可以try / catch
实例化,但我已经尝试过,但self.ReportServiceStatus(win32service.SERVICE_ERROR_CRITICAL)
似乎仍然无法向用户报告任何有意义的内容(理想情况下,以“服务无法启动,请检查配置”的形式出现。