I have some project which I build with jetty. I create server from code like
Server server = new Server(8082);
server.setHandler(new DefaultRequestHandler());
server.start();
server.join();
It's very useful when develop app, but is the proper way to deploy such app to server? I can build a jar from it and run it as
java -jar server.jar
Is it ok or I should install jetty and deploy my app as war? The problems I have with running simple jar is that I deploy it remote machine, and if I run it as type it will run in main thread in console, so I can't do anything in that console window. If I close console window it will kill the process. I can start it as
java -jar server.jar &
And it will go to background, but I have no way to stop server than. Only with kill command. Also I find there is some start.jar which can start jetty, but I did not found descriptive examples when and how exactly use it.
And second problem I have is with logs. It prints all the logs to console or to /dev/null. Is there a way to handle log files somehow? I mean to have possibility store log for 3 days for example, and not write log in one file till space will end or while I'll manually delete log file. Does this handles server, or some logs libs such as log4j or something other?
I use centos7 as server.