Virgo Upstart config on Ubuntu 10.4

Posted in Linux Corner on January 23rd, 2012 by Friedrich Schäuffelhut – 1 Comment

Today I finally got sick of starting virgo on my Ubuntu 10.4 servers manually (using screen), being forced to check after each reboot for application servers waiting to be started. So I did my homework and wrote an upstart configuration. It turns out it isn’t that hard at all.Only little has to be done. I usually create a user named virgo and unzip the distribution (Virgo Web server 2.1.1)  in the newly created home directory.

sudo useradd -m -c 'Virgo Application Server'  -s /bin/bash virgo
sudo su - virgo
wget http://mirror.netcologne.de/eclipse//virgo/release/VWS/2.1.1.RELEASE/virgo-web-server-2.1.1.RELEASE.zip
unzip virgo-web-server-2.1.1.RELEASE.zip

Next the startup script needs to be fixed to replace itself with java using the exec call. Otherwise the shell script lingers between upstart and the java process. Which makes further configuration just a pain. sed comes in handy here.

sed -i 's/\$JAVA_HOME\/bin\/java/exec \$JAVA_HOME\/bin\/java/g' virgo-web-server-2.1.1.RELEASE/bin/dmk.sh

If you can’t use sed for what ever reason, take an editor, open the file web-server-2.1.1.RELEASE/bin/dmk.sh and look for any occurrence of $JAVA_HOME/bin/java. Prepend it with exec.

Nearly done. Exit the virgo users shell.

exit

Now copy this upstart configuration to /etc/init/virgo.conf.

description  "Virgo 2.1.1"
author       "Friedrich Schaeuffelhut"

start on (net-device-up
          and local-filesystems
          and runlevel [2345])
stop on runlevel [016]

console output
kill timeout 60
respawn

env JAVA_HOME=/opt/jdk1.6.0
env LANG=en_US.UTF-8

exec start-stop-daemon --signal INT --start --chuid virgo --exec /home/virgo/virgo-web-server-2.1.1.RELEASE/bin/startup.sh

Make sure to set the correct path to JAVA_HOME.
[UPDATE:] Also make sure to set the environment variable LANG. Java uses it to determine it’s default locale.

Voila! You might now start/stop your virgo appliaction server with these commands.

start virgo
stop virgo

Virgo will also be started on boot and stopped on a system shutdown.

One Comment on “ Virgo Upstart config on Ubuntu 10.4 ”

  • Miguel Salinas
    January 14th, 2013 17:25

    Hi Friedrich,

    Good script to resolve a ghost problem of deploy Virgo inside AWS Amazon Cloud. If you start the Virgo from the ssh shell, i obtained a timeout about 2 hour and a half, and the Virgo intance auto stop. Now running it with a daemon everything is OK.

    Best Regards

Leave a Reply


9 * five =