我想安装和启动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>