1

So I have a small situation. I am running a Java application on a Ubuntu 14.04 server. At one point, I opted to use Screen and some custom supervisor scripts to keep the application running. The supervisor process made sure the Java application was still running and restarted it if it failed and Screen was used to make it easy to connect back into the Java applications console should I need to interact with the applications CLI. Long story short, this technically worked, but it wasn't very stable. Occasionally Screen would stop working or the supervisor process would fail. They both had issues. I endured this configuration for a number of years. Finally I decided to go down a different route.

Currently (and for about the last year), the application has been running as a service. I believe it is using Upstart since systemd had not been rolled out as the default back then on 14.04 LTS. This new method of process control works like a dream come true. It is very easy to start and stop the Java application by treating it like a service. In addition, when the server boots or if the service fails, the OS handles the start/restart beautifully. So whats the problem? I can no longer access the Java console when starting the application this way. The only way I can get access to the Java console using this method is to shutdown the service, then manually launch the Java application. Interact with the console to make whatever changes are necessary. Shutdown the application, and then restart the service. You can see how this is not a good solution. This solution works great if you never need to interact with the console.

I tried launching the Java application inside screen as a service using Upstart, but this doesn't seem to work. So here is the official question:

How can I use Upstart to launch the Java Application in such a way that once the service is running I can SSH to the server and using some command can access the JVM console to issue CLI commands?

Here is some information from the server, including the Upstart script.

Thanks

root@ALPHA:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.4 LTS
Release:        14.04
Codename:       trusty

root@ALPHA:~# uname -r
3.19.0-65-generic

root@ALPHA:~# java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

# ALPHA START SCRIPT
start on runlevel [2345]
stop on runlevel [^2345]
console log
chdir /home/administrator/alpha
setuid administrator
setgid administrator
respawn
respawn limit 20 5
exec /usr/bin/java -Xms6G -Xmx12G -XX:PermSize=2G -jar alpha.jar nogui
Atomiklan
  • 405

0 Answers0