Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Start Jetty Properly

Tags:

java

ssh

jetty

this really silly question probably, as no one else seems to be having this problem. In the Jetty documentation it says jar -jar start.jar starts Jetty, and it does. But when I close my SSH console, obviously it dies.

How do I run it PROPERLY?

like image 262
Matthew H Avatar asked Jul 21 '10 01:07

Matthew H


People also ask

How do you start a jetty?

Start Jetty standalone from the JAR file. To start Jetty, switch on the command line to the installation directory and issue the following command. To stop Jetty press Ctrl + C . To start Jetty as Windows service you can use Apache Procrun.

What is Jetty process?

Eclipse Jetty is a Java web server and Java Servlet container. While web servers are usually associated with serving documents to people, Jetty is now often used for machine to machine communications, usually within larger software frameworks.

How do you set a jetty home window?

JETTY_HOME implies the path where jetty is installed and defined as JETTY_HOME on your environment variables. Too see the varible (path of the directory); based on your OS run echo %JETTY_HOME% for Windows; or echo $JETTY_HOME for Unix on your command line / terminal.


1 Answers

Is this for running on a production machine that will actually serve up an application running under Jetty? I assume this is the case, since you're asking about starting it properly.

If so, you need a proper process supervision system, such as runit, daemontools, monit, upstart, systemd, or good ol' SysV init.d (as mentioned w/ a gist). Which to use depends on your preferences, business needs, and often, your underlying operating system.

I use and prefer runit. It is built on solid principles (daemontools), and for my preferred distribution (Debian and Ubuntu) it is nicely packaged by the author himself.

Despite being recommended in other answers, and mentioned in comments, starting a long running process in screen/tmux, or via nohup is sub-optimal. You don't have any real control over the process. It won't be restarted if it dies. You have to manually find its PID and otherwise manually manage the service. You have to do more manual work to get the log output (redirection, sending to some random file, etc). You cannot reliably make it depend on other processes, or have other processes depend on it. Decent process supervision systems provide all this functionality for you by default.

If your goal is something else entirely, then please update the question to be more specific about your use case.

like image 91
jtimberman Avatar answered Oct 04 '22 00:10

jtimberman