2015-11-04 26 views
0

我有一個工作的Python Win32服務,試圖通過微星,與維克斯工具箱內置到分發。Python的服務 - 維克斯MSI安裝程序 - 自動啓動在啓動時不工作

但是,該服務被安裝爲「啓動類型自動」,開始安裝時,與sc命令開始,功能正常。

但是,當重新啓動計算機時,它不會自動啓動。它試圖啓動,但我在事件查看器中獲得2個錯誤 - > Windows日誌 - >系統

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。

   <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服務實現,如果需要

+0

是否依賴於還沒有拿出另一個服務?順便說一句,你可能想擦洗在這個例子中的密碼... – tdelaney

+0

謝謝,我已經擦洗它,並覆蓋複製和粘貼... D'哦.. 沒有依賴性,我認爲我在啓動時遇到了「自動」問題,如果網絡尚未加載,NYDPS域可能無法正常訪問,我正在測試延遲啓動 – Busturdust

+0

但是,這是從一些早期的變化迴歸,這使我困惑,爲什麼'auto'以前的工作,現在只有'延期'將工作..我已經經歷了一個解耦練習,我的服務現在導入多個自定義模塊,而不是沒有。我使用py2exe來捆綁它,但它不應該與1個文件 – Busturdust

回答

0

@tdelaney @PhilDW真正的答案..

FWIW - 一個python服務內使用time.sleep(),是進入無限循環這需要處理器時間。在無限循環內接收單曲是不可能的。有一個窗口服務實現完成睡眠

,而不是

sleep.time(10)

使用

#where timeout = sleep time

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

ñ方式OTE - sleep.time輸入以秒爲單位,win32event.WaitForSingleObject是毫秒

0

所以我想我想通了.. 每一行在服務啓動功能得到執行。

但是 - 最後一行代碼是致電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" /> 
相關問題