Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Sorry if this is a bit of a basic question, I'm fairly inexperienced with Ubuntu and Linux in general.

I am looking to upgrade an application server from JBoss EAP 5 to Jboss EAP 6, previously we have sent out customers instructions to run JBoss EAP 5 on startup so I'm looking to do the same for JBoss EAP 6. I've got it to work in one way, by adding the following line to /etc/rc.local:

sh /opt/jboss-eap-6.1/bin/domain.sh

Although from what I've read this isn't really a recommended approach. From what I can understand the approach we used for JBoss 5 involved putting a symbolic link into the run level initialisation directories (/etc/rc2.d/ for example) that referenced another script in /etc/init.d to start the service.

I've tried this for JBoss 6.1, and although if I manually start the process up with "sh /etc/rc2.d/S01jboss6.1", JBoss starts to run, this process does not run of it's own accord on startup.

I believe I'm correct in thinking Ubuntu starts up in run level 2 so is it not the case that this script in /etc/rc2.d/ should run when the OS is booted?

Thanks.

share|improve this question

1 Answer 1

I don't know JBoss. Is your script a one shot or does it keep running? For services that keep in foreground (on a terminal) and stay running you can write an upstart service something like the following. If it is a one shot or spawns a daemon process you need to edit the start script below, otherwise upstart won't have control over the process or tries to execute it several times.

The script needs to be executable and in /etc/init/myscript.conf. Then make a symbolic link from /etc/init.d/myscript to /lib/init/upstart-job

ln -s /lib/init/upstart-job /etc/init.d/myscript

You can start your script like this: service myscript start

description     "myscript"
author          "you"

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

kill timeout 50

respawn
respawn limit 1 5

env USER="user"
env PIDFILE="/var/run/myscript.pid"
env DAEMON="path/to/script"

pre-start script
  do smothing
end script

# starting ...
exec start-stop-daemon --start --chuid $USER --pidfile $PIDFILE --make-pidfile --exec $DAEMON -- all my options 2>&1 >> /var/log/my.log

pre-stop script
        do something
        sleep 2
end script

# spring clean
post-stop exec rm -f $PIDFILE

For more infos see : http://upstart.ubuntu.com/cookbook/

share|improve this answer
    
JBoss is a Java application server, so it should start up when the OS starts up and keep running until the server shuts down again. I was under the impression upstart was a Ubuntu specific technology , am I correct in thinking that? - I was hoping to keep the solution generic to Linux and applicable to other OSs (Red hat ES linux, SUSE linux). There was a service script that comes with JBoss unforunately it doesn't seem to work since it expects a 'functions' script in /etc/init.d that is on neither Ubuntu or SUSE linux. –  Potato Man Jan 23 at 10:23
    
Upstart is mainly developed by Canonical and almost exclusively used by Ubuntu and it's derivatives. It is possible to install upstart on other distros but probably not recommended. If you are planning for the future you should take systemd into account. The old System5 script will at some point be outdated, although not in the near future. see link –  Johannes Jan 23 at 11:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.