I've got a dotnet API running on my raspberry, when I lauch the executable manually, it listens on
http://<raspberry_ip>:<custom-port>
as configured on my appsettings.json
but when I use it as a service on my raspberry boot, it lauches on http://localhost:5000
.
I know something must be missing in my /lib/systemd/system/<app>.service
but I failed to see what.
My service configuration :
[Unit]
Description=Lauches API on boot
After=multi-user.target
[Service]
ExecStart=/home/<user>/Dev/<app_executable>
User=<user>
[Install]
WantedBy=multi-user.target
It seems quite strange, is this because of the moment the service lauches (too soon?) or am I missing something else in my configuration ?
Thanks a lot.
Ps: I also tried to change ExecStart
and provide my dotnet path like so :
ExecStart = /<dotnet_path> /<app_path>.dll
but it didn't work either.
You need to set the WorkingDirectory
parameter.
According to the docs:
WorkingDirectory=
Takes a directory path relative to the service's root directory specified by RootDirectory=, or the special value "~". Sets the working directory for executed processes. If set to "~", the home directory of the user specified in User= is used. If not set, defaults to the root directory when systemd is running as a system instance and the respective user's home directory if run as user. If the setting is prefixed with the "-" character, a missing working directory is not considered fatal. If RootDirectory=/RootImage= is not set, then WorkingDirectory= is relative to the root of the system running the service manager. Note that setting this parameter might result in additional dependencies to be added to the unit (see above).