Reputation: 5369
I have a an application I am trying to run with mono through systemd on ubuntu When I run
systemctl status myservice.service
I get the following:
Loaded: loaded (/lib/systemd/system/myservice.service; bad; vendor preset: enabled)
Active: inactive (dead)
My service file is as follows:
[Unit]
Description=The description
After=network.target
[Service]
User=theuser
ExecStart=/usr/bin/mono -- /home/pathtoservice/myapplication.exe --parameter1=p1 --parameter2=p2
[Install]
WantedBy=multi-user.target
I have ran:
/usr/bin/mono -- /home/pathtoservice/myapplication.exe --parameter1=p1 --parameter2=p2
from the command line and it works. Any ideas on what is wrong?
I presume it is in service file but have looked at other examples and cant see what is wrong with it. New to ubuntu so not sure where to look to diagnose the issue
Upvotes: 0
Views: 1551
Reputation: 13401
First, check your logs:
journalctl -u myservice.service
Adding this to your unit file may improve the logging:
StandardOutput=journal+console
In some cases if some logging happens just before the service exits, the logs won't get tagged with the the service, so after you run the service, also look at:
journalctl
For entries just after your service exited.
Also, instead using the network.target
, try the network-online.target
.
I presume the app runs OK from the command line by itself. Assuming it works that way and not from systemd, differing environment variables can be an issue. Add a line to the top of your app to dump all the environment variables and compare that output when run from systemd
vs the CLI.
Finally, review the docs for Type=. If the default Type= doesn't apply to your case, set this appropriately.
Future questions specific to systemd
may be better answered at the Unix & Linux StackExchange as they don't directly relate to programming.
Upvotes: 2