In a recent project, we had to use a raspberry pi as an edge controller for remote monitoring an Industrial shilling machine.
Our Software team is more experienced in C# /
Step One; go to this directory in your RPi
$ cd /etc/systemd/system
Step two; issue this command to create new file and open editor:
$ sudo nano serviceName.service // this create a file with the name of your service
Step three; type the following lines in the file.
[Unit] Description=BSCC service [Service] ExecStart=/bin/dotnet/dotnet /home/pi/BSCC/RaspberryPi.dll WorkingDirectory=/home/pi/BSCC/ User=root Group=root Restart=on-failure SyslogIdentifier=dscc-service PrivateTmp=true Type=idle [Install] WantedBy=multi-user.target
after that save the file, if you are using nana editor like me use the following command
Ctrl+X. then answer yes to the save quastion
Now having the service ready we need to call the following commands in sequence, it may need the use of
$ sudo systemctl daemon-reload $ sudo systemctl enable serviceName.service $ sudo systemctl start serviceName.service
after this point your service is running, to check on it or do any changes you can use any of the following commands:
to check status: $ sudo systemctl status serviceName.service to start : $ sudo systemctl start serviceName.service to stop: $ sudo systemctl stop serviceName.service to restart: $ sudo systemctl restart serviceName.service
for debugging purposes and following up on any log messages you application write you can use this command.
journalctl --unit serviceName.service --follow