How to execute crate with systemd service?

Trying to launch systemd service for crate installed with cargo install ,
but get following error:

Failed at step EXEC spawning /home/pulsarss/.cargo/bin/pulsarss: Permission denied

The service loolks like that:

# /etc/systemd/system/pulsarss.service

[Unit]
After=network.target

[Service]
Type=simple
User=pulsarss
Group=pulsarss
ExecStart=/home/pulsarss/.cargo/bin/pulsarss -s https://path/to/feed.rss -i index.gmi

[Install]
WantedBy=multi-user.target

Of course I can change the permissions, but not sure that's right way.

I found this answer on serverfault, and agree that issue would be related to system security implementation.

When running the binary from bash, the rustup is maybe cares of that by linking the paths.

By copying binary to this location, I've fixed the issue

sudo cp /home/pulsarss/.cargo/bin/pulsarss /usr/local/bin

I think this way is correct because means manual app installation according to the system requirements I use. The rights change is maybe not best idea.

Anyway, interesting your opinion or how do you work with systemd+rust apps

If you want to use your locally-instapped app as systemd service (including ones made with cargo install), you likely want to reach for user services, not system-wide ones. If you want to use system-wide service, well, you have to somehow install the app system-wide, be it manual cping or using system package manager.

1 Like