I'm using vagrant to emulate services with network communication. My base box is the ubuntu/bionic64. The application that I'm porting to the VM is written in C++ and binds to ipc addresses as follows:
sink.bind("ipc:///var/run/dummy-service");
So after compiling and installing this service in /usr/bin/, I used systemctl to create the desired service with the following service file:
[Unit]
Description=dummy manipulator
After=network-online.target
Wants=network-online.target
[Service]
Type=forking
PIDFile=/run/dummy-service.pid
ExecStart=/usr/bin/dummy-service
[Install]
WantedBy=multi-user.target
as for the location of the service file: $HOME/.config/systemd/user/dummy.service
So when I run the following command:
systemctl --user enable dummy.service
systemctl --user start dummy.service
It gives an exit code error when running its status:
dummy.service - belt and electrodes status manipulator
Loaded: loaded (/home/vagrant/.config/systemd/user/dummy.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2021-01-28 23:52:58 UTC; 18s ago
Process: 22420 ExecStart=/usr/bin/dummy-service (code=exited, status=1/FAILURE)
Jan 28 23:52:58 ubuntu-bionic systemd[20920]: Starting dummy manipulator...
Jan 28 23:52:58 ubuntu-bionic systemd[20920]: dummy.service: Control process exited, code=exited status=1
Jan 28 23:52:58 ubuntu-bionic systemd[20920]: dummy.service: Failed with result 'exit-code'.
Jan 28 23:52:58 ubuntu-bionic systemd[20920]: Failed to start dummy manipulator.
What I discovered after was that of a permission error because the service is not allowed to run in /var/run/. When I switched the binding to sink.bind("ipc:///tmp/dummy-service");, the service apparently ran without issue:
dummy.service - dummy manipulator
Loaded: loaded (/home/vagrant/.config/systemd/user/dummy.service; enabled; vendor preset: enabled)
Active: activating (start) since Fri 2021-01-29 00:06:04 UTC; 30s ago
What should I do to run my service with the binding to the /var/run address?
I've already trying installing the binary as a superuser, I've tried changing the binary's permissions with chmod 777. I've tried altering options in the service file:
User=root
Group=root
All without success.