Skip to content

Instantly share code, notes, and snippets.

@IshamMohamed
Created June 6, 2020 05:03
Show Gist options
  • Save IshamMohamed/0cdc065dd327edc91bcb59a5ae9dae93 to your computer and use it in GitHub Desktop.
Save IshamMohamed/0cdc065dd327edc91bcb59a5ae9dae93 to your computer and use it in GitHub Desktop.
[Unit]
Description=Long running service/daemon created from .NET worker template
[Service]
Type=notify
# will set the Current Working Directory (CWD). Worker service will have issues without this setting
WorkingDirectory=/srv/cisworker
# systemd will run this executable to start the service
ExecStart=/srv/cisworker/cis.worker.demo
# to query logs using journalctl, set a logical name here
SyslogIdentifier=cisworker
# Use your username to keep things simple.
# If you pick a different user, make sure dotnet and all permissions are set correctly to run the app
# To update permissions, use 'chown isham -R /srv/cisworker' to take ownership of the folder and files,
# Use 'chmod +x /srv/cisworker/cis.worker.demo' to allow execution of the executable file
User=isham
# ensure the service restarts after crashing
Restart=always
# amount of time to wait before restarting the service
RestartSec=5
# This environment variable is necessary when dotnet isn't loaded for the specified user.
# To figure out this value, run 'env | grep DOTNET_ROOT' when dotnet has been loaded into your shell.
Environment=DOTNET_ROOT=/home/isham/dotnet
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment