【问题标题】:Python Service - Wix MSI Installer - Auto Start on bootup not workingPython 服务 - Wix MSI 安装程序 - 启动时自动启动不起作用
【发布时间】:2016-02-05 09:03:27
【问题描述】:

我有一个可用的 python win32 服务,试图通过使用 WiX 工具集构建的 msi 分发它。

但是,该服务被安装为“自动启动类型”,在安装时启动,以sc 命令启动,并且运行正常。

但是当重新启动计算机时,它不会自动启动。它尝试启动,但在事件查看器 -> Windows 日志 -> 系统中出现 2 个错误

A timeout was reached (30000 milliseconds) while waiting for the Edit Service service to connect.

The Edit Service service failed to start due to the following error: The service did not respond to the start or control request in a timely fashion.

这是引用 serviceinstall 的 WiX 部分。

             <File Id="MainEXE" Source="editservice.exe" KeyPath="yes"/>
                    <ServiceControl Id="Edit" Name=Edit Service" Start="install" Stop="both" Remove="uninstall" Wait="yes" />


                    <ServiceInstall 
                        Id="service" 
                        Account="\Ps" 
                        Password="scrubed$" 
                    Start="auto" 
                    ErrorControl="normal" 
                    Name="Edit Service" 
                    Type="ownProcess" 
                    Vital="yes"      />

                    <RemoveFolder Id="Purge"  On="uninstall" />

任何想法为什么只有在系统启动时才会启动?如果需要,我可以提供进一步的 WiX 或 python 服务实现

【问题讨论】:

  • 它是否依赖于另一个尚未出现的服务?顺便说一句,您可能想在示例中清除该密码...
  • 谢谢,我已经擦洗了它,并用复制和粘贴覆盖了... D'oh.. 没有依赖,我认为我在启动时遇到了“自动”问题,如果网络尚未加载,NYDPS 域可能无法正确访问,我正在测试延迟启动
  • 然而,这是对一些早期变化的回归,这让我很困惑为什么 auto 以前可以工作,而现在只有 deferred 可以工作。我已经进行了脱钩练习,我的服务现在导入多个自定义模块,而不是没有。我使用 py2exe 捆绑它,但它应该与 1 个文件没有任何不同
  • “服务没有及时响应启动或控制请求。”显然不是安装问题。该服务的启动逻辑很慢或失败,它花费的时间太长。调试服务,而不是安装!
  • @PhilDW 同意,但服务工作正常如果我手动启动它,它会在一秒钟内立即启动,我以为这是我分发它的方式......服务无法在启动时启动,如果是服务中的问题,它应该无法在其他地方启动

标签: python wcf service wix windows-installer


【解决方案1】:

@tdelaney @PhilDW 真正的答案..

FWIW - 在 python 服务中使用time.sleep() 是进入一个无限循环,这需要处理器时间。在无限循环中接收单曲是不可能的。有一个 windows 服务实现方法来完成睡眠

而不是

sleep.time(10)

使用

#where timeout = sleep time

if win32event.WaitForSingleObject(self.hWaitStop, timeout) == win32event.WAIT_OBJECT_0: break

注意 - sleep.time 输入以秒为单位,win32event.WaitForSingleObject 以毫秒为单位

【讨论】:

    【解决方案2】:

    所以我想我想通了。服务启动函数中的每一行都会被执行。

    然而 - 最后一行代码是对 time.sleep(10) 的调用。这行代码似乎没有完成运行,导致启动失败即使服务正在运行。

    在生产中,睡眠时间将增加到一个小时。因此,我认为 延迟启动 是首选方法。

    为了在 WiX 中执行此操作,请遵循以下代码模板。

                     <ServiceControl Id="Edit" Name="NBC Edit Service" Start="install" Stop="both" Remove="uninstall" Wait="yes" />
    
    
                        <ServiceInstall 
                            Id="service" 
                            Account="NYDPS\Portus" 
                            Password="getyourownpassword" 
                            Start="auto"
                            ErrorControl="normal"
                            Name="NBC Edit Service"
                            Type="ownProcess"
                            Vital="yes" >
    
                            <ServiceConfig DelayedAutoStart="yes" OnInstall="yes" OnReinstall ="yes" />
                        </ServiceInstall>
    
                        <RemoveFolder Id="Purge"  On="uninstall" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-03
      • 1970-01-01
      • 2010-12-07
      相关资源
      最近更新 更多