I have created a Linux service definition (file: myservice.service) like this:
[Unit]
Description=MyService
[Service]
ExecStart=/home/user1/myservicefolder/myservice
Restart=always
RestartSec=10
SyslogIdentifier=myservice
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=default.target
Then I (logged in as user) enable the service by doing
systemctl --user enable ./myservice.service
Then I can without any issues start the service in SSH by doing (logged in as user1 and naturally without sudo):
systemctl --user start myservice.service
This works perfect but I want to automate the restarting of this service due to CICD in Azure Pipelines. So I have configured the agent to runt as user1 and I have created a Command Line pipeline step with the following commands:
whoami
systemctl --user start myservice.service
Then I run this with Azure Pipeline Releases and output line 1 shows correctly “user1” but then I get the error
Failed to connect to bus: No medium found
How can I fix this issue I am totally stuck on what is wrong? I’m running Debian. I have tried a lot of different combinations and syntaxes but keep getting that error. I have also just tried a step with “systemctl –user status” and it still gives such an error.