【问题标题】:Using WiX to install a Node server as a Windows Service使用 WiX 将节点服务器安装为 Windows 服务
【发布时间】:2016-07-01 12:19:57
【问题描述】:

有谁知道如何使用 WiX (Windows Installer XML) 安装节点服务器并将其作为 Windows 服务启动?

目前该应用程序没有 .exe 文件,只有一个运行“node app.js”的 bat 文件来启动服务器。我想知道是否可以使用 wix 将其安装为服务,还是必须先将其转换为 .exe 文件?

【问题讨论】:

标签: node.js wix windows-installer wix3.10


【解决方案1】:

您可以使用 srvany.exe 获取任何类型的脚本/可执行文件并将其作为服务托管。 WiX 然后看起来像:

<Component Id="c1" Guid="someguid">
  <File Id="f1" Source="$(var.SourceDir)\srvany.exe" KeyPath="yes" />
  <ServiceInstall Id="si1" DisplayName="servicedisplay" Description="servicedesc" Name="servicename" Start="auto" Type="ownProcess" Vital="no" ErrorControl="normal" Account="NT AUTHORITY\NetworkService"  />
  <ServiceControl Id="sc1S" Name="servicename" Remove="both" Stop="both" Start="install" Wait="yes" />
  <RegistryValue Id="reg1" Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\ExpertChatPeerServer\Parameters" Name="Application" Type="string" Value="node &quot;[#f2]&quot;" Action="write" />
</Component>
<Component Id="c2" Guid="someguid" KeyPath="yes">
  <File Id="f2" Source="$(var.SourceDir)\somenodescript.js" />
</Component>

【讨论】:

  • 这似乎安装了服务,但安装程序挂在“启动服务”上并最终给出一个关于需要正确权限的错误?这是因为节点服务器代码不是有效的 Windows 服务吗?
  • 如果您的(服务)脚本没有其他问题,它应该可以工作。 1920 不正确的权限消息总是用词不当。你必须运行你的程序,看看它是否抛出错误或挂起。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多