aboutsummaryrefslogtreecommitdiff
path: root/src/zenutil/service.cpp
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2025-01-15 10:17:02 +0100
committerDan Engelbrecht <[email protected]>2025-01-15 10:17:02 +0100
commit53531a6b22dbb7b690db43964172e9d0f670c3c8 (patch)
treeeb826db2e3f8601df32f166f96fa291cc9e80de3 /src/zenutil/service.cpp
parentsystemd unit file, incomplete (diff)
downloadzen-53531a6b22dbb7b690db43964172e9d0f670c3c8.tar.xz
zen-53531a6b22dbb7b690db43964172e9d0f670c3c8.zip
clang format
Diffstat (limited to 'src/zenutil/service.cpp')
-rw-r--r--src/zenutil/service.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/zenutil/service.cpp b/src/zenutil/service.cpp
index 820edf565..45874d1b5 100644
--- a/src/zenutil/service.cpp
+++ b/src/zenutil/service.cpp
@@ -280,13 +280,13 @@ namespace {
}
}
- while(!Data.empty() && isspace(Data[Data.length() - 1]))
+ while (!Data.empty() && isspace(Data[Data.length() - 1]))
{
Data.pop_back();
}
- int Res = -1;
- int Status = pclose(Stream);
+ int Res = -1;
+ int Status = pclose(Stream);
if (Status < 0)
{
return {Status, Data};
@@ -296,7 +296,7 @@ namespace {
{
Res = WEXITSTATUS(Status);
}
- if (Res != 0 && Res != (128+13))
+ if (Res != 0 && Res != (128 + 13))
{
return {Res, Data};
}
@@ -883,10 +883,10 @@ InstallService(std::string_view ServiceName, const ServiceSpec& Spec)
{
// TODO: Do we need to create a separate user for the service or is running as root OK?
- const std::string UnitName = GetUnitName(ServiceName);
+ const std::string UnitName = GetUnitName(ServiceName);
const std::filesystem::path ServiceUnitPath = GetServiceUnitPath(UnitName);
- std::string UnitFile = BuildUnitFile(ServiceName, Spec.ExecutablePath, Spec.CommandLineOptions, UnitName);
+ std::string UnitFile = BuildUnitFile(ServiceName, Spec.ExecutablePath, Spec.CommandLineOptions, UnitName);
ZEN_DEBUG("Writing systemd unit file to {}", ServiceUnitPath.string());
try
{
@@ -923,7 +923,7 @@ InstallService(std::string_view ServiceName, const ServiceSpec& Spec)
std::error_code
UninstallService(std::string_view ServiceName)
{
- const std::string UnitName = GetUnitName(ServiceName);
+ const std::string UnitName = GetUnitName(ServiceName);
const std::filesystem::path ServiceUnitPath = GetServiceUnitPath(UnitName);
std::pair<int, std::string> Res = ExecuteProgram(fmt::format("systemctl disable {}", UnitName));
@@ -955,7 +955,7 @@ UninstallService(std::string_view ServiceName)
std::error_code
QueryInstalledService(std::string_view ServiceName, ServiceInfo& OutInfo)
{
- const std::string UnitName = GetUnitName(ServiceName);
+ const std::string UnitName = GetUnitName(ServiceName);
const std::filesystem::path ServiceUnitPath = GetServiceUnitPath(UnitName);
OutInfo.Status = ServiceStatus::NotInstalled;
@@ -973,7 +973,7 @@ QueryInstalledService(std::string_view ServiceName, ServiceInfo& OutInfo)
}
else
{
- ZEN_DEBUG("systemctl status failed with '{}" ({}), Res.second, Res.first);
+ ZEN_DEBUG("systemctl status failed with '{}"({}), Res.second, Res.first);
}
}
@@ -988,7 +988,7 @@ StartService(std::string_view ServiceName)
// Starting the same command line for the service using `sudo` *will* start the service sucessfully so I
// assume that the Unit file or some config is wrong/missing.
- const std::string UnitName = GetUnitName(ServiceName);
+ const std::string UnitName = GetUnitName(ServiceName);
const std::filesystem::path ServiceUnitPath = GetServiceUnitPath(UnitName);
std::pair<int, std::string> Res = ExecuteProgram(fmt::format("systemctl start {}", UnitName));
@@ -1004,9 +1004,10 @@ StartService(std::string_view ServiceName)
std::error_code
StopService(std::string_view ServiceName)
{
- // TODO: Stopping the service returns -1 from ExecuteProgram, maybe this ie expected as I have yet to successfully start the service using systemctl start
+ // TODO: Stopping the service returns -1 from ExecuteProgram, maybe this ie expected as I have yet to successfully start the service
+ // using systemctl start
- const std::string UnitName = GetUnitName(ServiceName);
+ const std::string UnitName = GetUnitName(ServiceName);
const std::filesystem::path ServiceUnitPath = GetServiceUnitPath(UnitName);
std::pair<int, std::string> Res = ExecuteProgram(fmt::format("systemctl stop {}", UnitName));