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:
parent
8745feb567
commit
1b4eea79d8
1 changed files with 18 additions and 0 deletions
|
@ -95,6 +95,9 @@ Function Nssm-Install
|
|||
{
|
||||
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))
|
||||
{
|
||||
|
@ -138,6 +141,21 @@ Function Nssm-Install
|
|||
$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()
|
||||
|
|
Loading…
Reference in a new issue