Добавил запуск и остановку служб

This commit is contained in:
Антон Чичков 2024-07-18 12:15:04 +10:00
parent b35528ff71
commit 3261a320c8

View File

@ -57,7 +57,9 @@ $serverExecutable = "$lersDir/Server/Lers.Server.dll"
$pollServiceExecutable = "$lersDir/PollService/Lers.PollService.dll" $pollServiceExecutable = "$lersDir/PollService/Lers.PollService.dll"
$serverServiceName = "lers.server.service" $serverServiceName = "lers.server.service"
$serverServiceFile = "/etc/systemd/system/$serverServiceName"
$pollserviceServiceName = "lers.pollservice.service" $pollserviceServiceName = "lers.pollservice.service"
$pollserviceServiceFile = "/etc/systemd/system/$pollserviceServiceName"
################################### ###################################
# Ресурсы # Ресурсы
@ -122,9 +124,8 @@ else
$pollServiceUrl = "https://update.lers.ru/download/files/PollService.zip" $pollServiceUrl = "https://update.lers.ru/download/files/PollService.zip"
} }
$isServerInstalled = Test-Path -Path $serverExecutable $isServerInstalled = Test-Path -Path $serverServiceFile
$isPollServiceInstalled = Test-Path -Path $pollServiceExecutable $isPollServiceInstalled = Test-Path -Path $pollserviceServiceFile
## Останавливаем запущенные службы, если они есть ## Останавливаем запущенные службы, если они есть
@ -262,11 +263,25 @@ else
if ($server) if ($server)
{ {
$serverSystemd | Set-Content /etc/systemd/system/$serverServiceName -Force $serverSystemd | Set-Content $serverServiceFile -Force
} }
if ($pollservice) if ($pollservice)
{ {
$pollserviceSystemd | Set-Content /etc/systemd/system/$pollserviceServiceName -Force $pollserviceSystemd | Set-Content $pollserviceServiceFile -Force
} }
} }
# Запускаем службы
systemctl daemon-reload
if ($isServerInstalled)
{
systemctl start $serverServiceName
}
if ($isPollServiceInstalled)
{
systemctl start $pollserviceServiceName
}