1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

win_nssm: set application directory on change of application binary (#3267)

This commit is contained in:
Hans-Joachim Kliemeck 2016-10-27 11:56:08 +02:00 committed by Matt Clay
parent 8745feb567
commit 1b4eea79d8

View file

@ -95,6 +95,9 @@ Function Nssm-Install
{ {
Throw "Error installing service ""$name"". No application was supplied." Throw "Error installing service ""$name"". No application was supplied."
} }
If (-Not (Test-Path -Path $application -PathType Leaf)) {
Throw "$application does not exist on the host"
}
if (!(Service-Exists -name $name)) if (!(Service-Exists -name $name))
{ {
@ -138,6 +141,21 @@ Function Nssm-Install
$result.changed = $true $result.changed = $true
} }
} }
if ($result.changed)
{
$applicationPath = (Get-Item $application).DirectoryName
$cmd = "nssm set ""$name"" AppDirectory $applicationPath"
$results = invoke-expression $cmd
if ($LastExitCode -ne 0)
{
Set-Attr $result "nssm_error_cmd" $cmd
Set-Attr $result "nssm_error_log" "$results"
Throw "Error installing service ""$name"""
}
}
} }
Function ParseAppParameters() Function ParseAppParameters()