Hey. In Linux, I am a beginner ... There are VDS with Debian, clean, set only Maven and Apache. There is a java server application that I run in Maven: mvn exec: java After the ssh connection to the server is lost, or the java server is just waiting for a long time. Running through php exec () works, but this is not what I wanted.

The question is how to start a java server application in maven so that it works after a reboot, for example init.d or something else?

  • Do you have to use maven to launch the application? Usually with the help of maven they collect war or jar, and they are started using tomcat, for example - Alexander
  • @ Alexander I honestly do not know how to run better and through what, but you need to run it - github.com/mrniko/netty-socketio Tomkat is the best solution for this task? - Sergey
  • @ Alexander run in the service of the normal version? I mean throw in init.d / startserverscript where the jar will be launched in the service using java tools: java -jar name.jar ..... as long as it works, but is this correct in terms of correctness? or is it still better to use tomkat-specific products for this? - Sergey

1 answer 1

If you need to start the application at system startup - init.d is what you need. But pay attention to the user, on behalf of whom the process will be launched. Running an application as root is potentially dangerous for a public server.

There is also a screen utility that allows you to minimize the running application, terminate the ssh connection, but leave the process running in the session alive and working. After a new connection via ssh screen, this process can "deploy".

If we are talking about servlets, then I suggest using tomcat or analogues.

I will also pay attention to the fact that monitoring the fall of the application itself is not the responsibility of everything described above, but for this you can write a separate script.

  • Thank you very much, I will think that it is better to use. So far put cron on a script which starts the application in the java service (that is, the server). - Sergey