I have written a Java server application that runs on a standard virtual hosted Linux solution. The application runs all the time listening for socket connections and creating new handlers for them. It is a server side implementation to a client-server application.
The way I start it is by including it in the start up rc.local script of the server. However once started I do not know how to access it to stop it and if I want to install an update, so I have to restart the server in order to restart the application.
On a windows PC, for this type of application I might create a windows service and then I can stop and start it as I want. Is there anything like that on a Linux box so that if I start this application I can stop it and restart it without doing a complete restart of the server.
My application is called WebServer.exe. It is started on server startup by including it in my rc.local as such:
java -jar /var/www/vhosts/myweb.com/phpserv/WebServer.jar &
I am a bit of a noob at Linux so any example would be appreciated with any posts. However I do have SSH, and full FTP access to the box to install any updates as well as access to a Plesk panel.
I wrote another simple wrapper here:
You can follow a full tutorial for init.d here and for systemd (ubuntu 16+) here
If you need the output log replace the
2
lines for
Maybe not the best dev-ops solution, but good for the general use of a server for a lan party or similar.
Use
screen
to run your server in and then detach before logging out, this will keep the process running, you can then re-attach at any point.Workflow:
Start a screen:
screen
Start your server:
java -jar minecraft-server.jar
Detach by pressing:
Ctl-a
,d
Re-attach:
screen -r
More info here: https://www.gnu.org/software/screen/manual/screen.html