|
04-03-2020, 01:20 AM
|
#1
|
Human being with feelings
Join Date: Mar 2020
Posts: 35
|
Steps for turning ninjam server into a service on linux (systemd)
1) Choose a name for the service. In this example the name is "ninjam1".
2) Choose a local linux user to run the service. The user should have permissions to run the ninjam executable and to write to the logfile specific in the ninjam config.
3) As root, create the unit file for systemd, e.g:
vi /etc/systemd/system/ninjam1.service
4) Enter the text below and save. Replace items in <>
[Unit]
Description=Ninjam 1 Service
After=network.target multi-user.target
[Service]
Type=simple
User=<user>
ExecStart=<path>/ninjamsrv <path>/<ninjam_config_file>
Restart=always
RestartSec=1
[Install]
Alias=
5) Enter the following commands:
systemctl daemon-reload
systemctl start ninjam1
6) Check for errors with commands such as :
systemctl status ninjam1
tail /var/log/messages
Otherwise try to connect to your server from a ninjam client.
7) If everything works:
systemctl enable ninjam1
|
|
|
04-03-2020, 08:43 AM
|
#2
|
Human being with feelings
Join Date: Mar 2007
Posts: 3,978
|
Thanks for sharing ozprog,
can you say what is an advantage of being a service?
|
|
|
04-03-2020, 01:46 PM
|
#3
|
Human being with feelings
Join Date: Aug 2007
Location: London, UK
Posts: 767
|
It's the modern way of running things on *nix systems.
(I'm old school and use /etc/init.d scripts... systemd understands how to deal with them, though.)
__________________
Quote:
Originally Posted by Tony Williams
...Playing fast around the drums is one thing. But to play with people for others, to listen to, that's something else. That's a whole other world.
|
|
|
|
04-03-2020, 04:29 PM
|
#4
|
Human being with feelings
Join Date: Mar 2007
Posts: 3,978
|
Quote:
Originally Posted by pljones
It's the modern way of running things on *nix systems.
(I'm old school and use /etc/init.d scripts... systemd understands how to deal with them, though.)
|
I use it the same way (/etc/init.d ...)
|
|
|
04-03-2020, 10:25 PM
|
#5
|
Human being with feelings
Join Date: Mar 2020
Posts: 35
|
Quote:
Originally Posted by akademie
Thanks for sharing ozprog,
can you say what is an advantage of being a service?
|
Sure, your server will always be running in the background, and be started and restated automatically by the system, e.g. after reboot.
If you are running ninjam from the command-line (or GUI) you will need to stay logged in. As soon as you log out any processes you started like Ninjam are also closed.
This would also make it easier to run multiple ninjam servers on the same machine.
Not everyone will want this.
Edit: initd works too, but hey, systemd is here to stay.
|
|
|
04-04-2020, 12:43 AM
|
#6
|
Human being with feelings
Join Date: Aug 2007
Location: London, UK
Posts: 767
|
Quote:
Originally Posted by ozprog
Edit: initd works too, but hey, systemd is here to stay.
|
Yep - and even with my /etc/init.d scripts, I use systemctl for control... at some point I'll update...
__________________
Quote:
Originally Posted by Tony Williams
...Playing fast around the drums is one thing. But to play with people for others, to listen to, that's something else. That's a whole other world.
|
|
|
|
04-04-2020, 03:28 AM
|
#7
|
Human being with feelings
Join Date: Mar 2007
Posts: 3,978
|
Quote:
Originally Posted by ozprog
Sure, your server will always be running in the background, and be started and restated automatically by the system, e.g. after reboot.
If you are running ninjam from the command-line (or GUI) you will need to stay logged in. As soon as you log out any processes you started like Ninjam are also closed.
This would also make it easier to run multiple ninjam servers on the same machine.
Not everyone will want this.
Edit: initd works too, but hey, systemd is here to stay.
|
Thanks for info ozprog,
yeah auto start/restart is good for sure.
About the part that I marked bold in a quote:
I use "screen" command to run ninjam server in screens.
I can detach from the screen then and the process is still running. This way I can run more screens each with its own process (here, ninjam server on different port for example).
If needed you can then atach to selected screen and stop the process etc...
Very handy.
info:
Screen command offers the ability to detach a long running process (or program, or shell-script) from a session and then attach it back at a later time. When the session is detached, the process that was originally started from the screen is still running and managed by the screen.
https://www.tecmint.com/screen-comma...inux Terminals
Last edited by akademie; 04-04-2020 at 03:34 AM.
Reason: info and link added
|
|
|
04-04-2020, 03:39 AM
|
#8
|
Human being with feelings
Join Date: Mar 2020
Posts: 35
|
Quote:
Originally Posted by akademie
Thanks for info ozprog,
yeah auto start/restart is good for sure.
About the part that I marked bold in a quote:
I use "screen" command to run ninjam server in screens.
I can detach from the screen then and the process is still running. This way I can run more screens each with its own process (here, ninjam server on different port for example).
If needed you can then atach to selected screen and stop the process etc...
Very handy.
info:
Screen command offers the ability to detach a long running process (or program, or shell-script) from a session and then attach it back at a later time. When the session is detached, the process that was originally started from the screen is still running and managed by the screen.
https://www.tecmint.com/screen-comma...inux Terminals
|
I didn't know screen had that capability to keep processes running, thanks. I assume it's no longer not dependant on the spawning process like with bg and fg?
You know, I tell myself I should learn screen literally every time I open a second terminal.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 02:18 AM.
|