我想安装并启动Redis
(对于Windows)作为我们软件包的一部分。安装和启动服务工作正常,但在安装过程中发生错误,然后回滚,并且在回滚后不会删除服务。
任何人都可以帮助我找出我在这里做错了什么吗?另外,我是否也需要单独的删除命令,或者也为卸载执行回滚工作?
(像[#fil5E85DBB2FFC8A2CFA55EDCADD8376C1F]这样的值是使用HeatDirectory为redis-server.exe及其目录生成的ID)
<!--Install Redis-->
<CustomAction Id="SetRedisInstall"
Property="RedisInstall"
Value=""[#fil5E85DBB2FFC8A2CFA55EDCADD8376C1F]" --service-install "[dir13BD3F7531FC8E0F30BB51FAA1B1357F]redis.windows.conf" --loglevel verbose" />
<CustomAction Id="RedisInstall"
BinaryKey="WixCA"
DllEntry="CAQuietExec"
Execute="deferred"
Return="check"
Impersonate="no"/>
<CustomAction Id="SetRedisStart" Property="RedisStart" Value=""[#fil5E85DBB2FFC8A2CFA55EDCADD8376C1F]" --service-start" />
<CustomAction Id="RedisStart"
BinaryKey="WixCA"
DllEntry="CAQuietExec"
Execute="deferred"
Return="check"
Impersonate="no"/>
<!--Rollback Redis-->
<CustomAction Id="SetRedisStop" Property="RedisStop" Value=""[#fil5E85DBB2FFC8A2CFA55EDCADD8376C1F]" --service-stop" />
<CustomAction Id="RedisStop"
BinaryKey="WixCA"
DllEntry="CAQuietExec"
Execute="rollback"
Return="ignore"
Impersonate="no"/>
<CustomAction Id="SetRedisRemove" Property="RedisRemove" Value=""[#fil5E85DBB2FFC8A2CFA55EDCADD8376C1F]" --service-uninstall" />
<CustomAction Id="RedisRemove"
BinaryKey="WixCA"
DllEntry="CAQuietExec"
Execute="ignore"
Return="asyncWait"
Impersonate="no"/>
<InstallExecuteSequence>
<!--Install Redis-->
<Custom Action="RedisInstall" Before="InstallFinalize">Not Installed</Custom>
<Custom Action="SetRedisInstall" Before="RedisInstall">Not Installed</Custom>
<Custom Action="RedisStart" After="RedisInstall">Not Installed</Custom>
<Custom Action="SetRedisStart" Before="RedisStart">Not Installed</Custom>
<!--Rollback Redis-->
<Custom Action="SetRedisStop" Before="RedisStop"></Custom>
<Custom Action="RedisStop" Before="RedisStart"></Custom>
<Custom Action="RedisRemove" Before="RedisInstall"></Custom>
<Custom Action="SetRedisRemove" Before="RedisRemove"></Custom>
</InstallExecuteSequence>
修改我有组件
<Feature Id="Redis" Title="Redis" Level="1" >
<ComponentGroupRef Id="RedisWxs"/>
</Feature>
现在也是服务部分:
<ServiceInstall Id="siRedisService" Description="Redis Service" DisplayName="Redis" Arguments=""[dir13BD3F7531FC8E0F30BB51FAA1B1357F]redis.windows.conf"" ErrorControl="normal" Name="Redis" Start="auto" Type="ownProcess" Vital="yes" Account="NT AUTHORITY\NetworkService"/>
<ServiceControl Id="scRedisService" Name="Redis" Start="install" Stop="both" Remove="both" Wait="yes" />
如何将服务添加到现有组件?
修改2
我已禁用自动收集并编辑输出文件,以便修复引用问题。我仍然遇到Redis服务无法启动的问题。但是,当我只是在cmd中复制粘贴路径(包括配置文件)时,它完全正常...
这是代码
<Component Id="cmp911C50BAA696496834114926A958787D" Guid="*">
<File Id="fil5E85DBB2FFC8A2CFA55EDCADD8376C1F" KeyPath="yes" Source="$(var.RedisPath)\redis-server.exe" />
<ServiceInstall Id="siRedisService" DisplayName="Redis" Arguments="--service-run redis.windows.conf --loglevel verbose" ErrorControl="normal" Name="Redis" Start="auto" Type="ownProcess" Vital="yes" Account="NT AUTHORITY\NetworkService"/>
<ServiceControl Id="scRedisService" Name="Redis" Start="install" Stop="both" Remove="both" Wait="yes" />
</Component>
<Component Id="cmpFC38C2953561FABFFCF29CCEC52692E1" Guid="*">
<File Id="filF5607FB03CD4B203C699DA14D17FF53B" KeyPath="yes" Source="$(var.RedisPath)\redis.windows.conf" />
</Component>
编辑3 - 工作解决方案
存在权限问题,这是我修复它的方式:
<Component Id="cmp911C50BAA696496834114926A958787D" Guid="*">
<File Id="fil5E85DBB2FFC8A2CFA55EDCADD8376C1F" KeyPath="yes" Source="$(var.RedisPath)\redis-server.exe" />
<CreateFolder Directory="dir13BD3F7531FC8E0F30BB51FAA1B1357F">
<util:PermissionEx User="NT AUTHORITY\NETWORKSERVICE" GenericAll="yes" />
</CreateFolder>
<ServiceInstall Id="siRedisService" DisplayName="Redis" Arguments="--service-run "[#filF5607FB03CD4B203C699DA14D17FF53B]"" ErrorControl="normal" Name="Redis" Start="auto" Type="ownProcess" Vital="yes" Account="NT AUTHORITY\NETWORKSERVICE"/>
<ServiceControl Id="scRedisService" Name="Redis" Start="install" Stop="both" Remove="both" Wait="yes" />
</Component>
答案 0 :(得分:1)
这肯定是很多自定义操作。我会摆脱它们。这是我如何滚动:
<Component Id="redacted" Guid="redacted">
<File Id="redacted" Source="$(var.SourceDir)\redis-server.exe" KeyPath="yes" />
<ServiceInstall Id="siRedisService" Description="Redis Service" DisplayName="Redis" Arguments="--service-run redis.windows.conf --loglevel verbose" ErrorControl="normal" Name="Redis" Start="auto" Type="ownProcess" Vital="yes" Account="NT AUTHORITY\NetworkService"/>
<ServiceControl Id="scRedisService" Name="Redis" Start="install" Stop="both" Remove="both" Wait="yes" />
</Component>
<Component Id="redacted" Guid="redacted">
<File Id="redacted" Source="$(var.SourceDir)\redis.windows.conf" KeyPath="yes" />
</Component>
我过去曾多次说过......服务是服务是服务。除了ServiceInstall和ServiceControl之外的任何其他内容以及偶尔的注册表项都是自我注册反模式疯狂的一种形式。服务可以用不同的语言编写,并由不同的运行时托管,但它们与服务控制管理器API的交互完全相同,一旦你计算出这些细节,MSI就可以本地处理它。