COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :

Go Back   Cockos Incorporated Forums > NINJAM Discussion > NINJAM Developer Discussion

Reply
 
Thread Tools Display Modes
Old 04-03-2020, 01:20 AM   #1
ozprog
Human being with feelings
 
Join Date: Mar 2020
Posts: 35
Default 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
ozprog is offline   Reply With Quote
Old 04-03-2020, 08:43 AM   #2
akademie
Human being with feelings
 
Join Date: Mar 2007
Posts: 3,978
Default

Thanks for sharing ozprog,
can you say what is an advantage of being a service?
akademie is offline   Reply With Quote
Old 04-03-2020, 01:46 PM   #3
pljones
Human being with feelings
 
pljones's Avatar
 
Join Date: Aug 2007
Location: London, UK
Posts: 767
Default

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.
pljones is offline   Reply With Quote
Old 04-03-2020, 04:29 PM   #4
akademie
Human being with feelings
 
Join Date: Mar 2007
Posts: 3,978
Default

Quote:
Originally Posted by pljones View Post
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 ...)
akademie is offline   Reply With Quote
Old 04-03-2020, 10:25 PM   #5
ozprog
Human being with feelings
 
Join Date: Mar 2020
Posts: 35
Default

Quote:
Originally Posted by akademie View Post
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.
ozprog is offline   Reply With Quote
Old 04-04-2020, 12:43 AM   #6
pljones
Human being with feelings
 
pljones's Avatar
 
Join Date: Aug 2007
Location: London, UK
Posts: 767
Default

Quote:
Originally Posted by ozprog View Post
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.
pljones is offline   Reply With Quote
Old 04-04-2020, 03:28 AM   #7
akademie
Human being with feelings
 
Join Date: Mar 2007
Posts: 3,978
Default

Quote:
Originally Posted by ozprog View Post
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
akademie is offline   Reply With Quote
Old 04-04-2020, 03:39 AM   #8
ozprog
Human being with feelings
 
Join Date: Mar 2020
Posts: 35
Default

Quote:
Originally Posted by akademie View Post
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.
ozprog is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 04:41 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.