Systemd microservice api to manage a systemd unit which is running in user space. Normally systemd services are configured with root user account and requires sudo permissions to manage service. Systemd microservice uses a systemd service with user configuration and enables user to manage systemd service with minimal permissions through an API. You can find details of configuring systemd as user here
You can configure the systemd service which is managed by micorservice in this config file
You can check the health of systemd service using the following get reqeust. Replace systemdd-service.local with your hostname.
curl -H "Accept: application/json" https://systemd-service.local:8080/api/v1/service/health
{
"statuscode": 200,
"unitname": "systemd-test-user.service",
"unitstatus": "systemd unit running"
}
You can start the systemd service using the following post reqeust. Replace systemdd-service.local with your hostname.
curl -X POST -H "Accept: application/json" https://systemd-service.local:8080/api/v1/service/start
{
"statuscode": 200,
"unitname": "systemd-test-user.service",
"unitstatus": "systemd unit started"
You can stop the systemd service using the following post reqeust. Replace systemdd-service.local with your hostname.
curl -X POST -H "Accept: application/json" https://systemd-service.local:8080/api/v1/service/stop
{
"statuscode": 200,
"unitname": "systemd-test-user.service",
"unitstatus": "systemd unit stopped"
}
You can restart the systemd service using the following post reqeust. Replace systemdd-service.local with your hostname.
curl -X POST -H "Accept: application/json" https://systemd-service.local:8080/api/v1/service/restart
{
"statuscode": 200,
"unitname": "systemd-test-user.service",
"unitstatus": "systemd unit restarted"
}