Start JBoss 7 as a service on Linux
After spending a couple of hours of snooping around I ended up creating /etc/init.d/jboss
with the following contents
#!/bin/sh
### BEGIN INIT INFO
# Provides: jboss
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/Stop JBoss AS v7.0.0
### END INIT INFO
#
#source some script files in order to set and export environmental variables
#as well as add the appropriate executables to $PATH
[ -r /etc/profile.d/java.sh ] && . /etc/profile.d/java.sh
[ -r /etc/profile.d/jboss.sh ] && . /etc/profile.d/jboss.sh
case "$1" in
start)
echo "Starting JBoss AS 7.0.0"
#original:
#sudo -u jboss sh ${JBOSS_HOME}/bin/standalone.sh
#updated:
start-stop-daemon --start --quiet --background --chuid jboss --exec ${JBOSS_HOME}/bin/standalone.sh
;;
stop)
echo "Stopping JBoss AS 7.0.0"
#original:
#sudo -u jboss sh ${JBOSS_HOME}/bin/jboss-admin.sh --connect command=:shutdown
#updated:
start-stop-daemon --start --quiet --background --chuid jboss --exec ${JBOSS_HOME}/bin/jboss-admin.sh -- --connect command=:shutdown
;;
*)
echo "Usage: /etc/init.d/jboss {start|stop}"
exit 1
;;
esac
exit 0
Here's the content of java.sh
:
export JAVA_HOME=/usr/lib/jvm/java_current
export PATH=$JAVA_HOME/bin:$PATH
And jboss.sh
:
export JBOSS_HOME=/opt/jboss/as/jboss_current
export PATH=$JBOSS_HOME/bin:$PATH
Obviously, you need to make sure, you set JAVA_HOME and JBOSS_HOME appropriate to your environment.
then I ran sudo update-rc.d jboss defaults
so that JBoss automatically starts on system boot
I found this article to be helpful in creating the start-up script above. Again, the script above is for Ubuntu (version 10.04 in my case), so using it in Fedora/RedHat or CentOS will probably not work (the setup done in the comments is different for those).
How to configure jboss to run as a service in rhel 7
You can check the coresponding JBoss EAP 7 documentation Installation Guide - Configuring JBoss EAP to run as a Service for detailed information.
Jboss as a service in Linux
I already answered this on serverfault
you have a typo in the first line
#!/bin/bash### BEGIN INIT INFO
#chkconfig: 345 90 10
it should be
#!/bin/bash
### BEGIN INIT INFO
#chkconfig: 345 90 10
How to start Jboss as 7 in command line
The user guide is pretty clear on how to to this :)
http://community.jboss.org/wiki/JBossAS7UserGuide
I suggest you try the standalone mode first (from the guide above):
If you want to work in standalone mode, open a terminal and cd into the distribution's bin directory, and run the "standalone" launch script:
$ cd bin
$ ./standalone.sh
On Windows:
> cd bin
> standalone.bat
How to start jboss 7.1.1 server and deploy project in jboss 7.1.1
Give JAVA_HOME environment variable in your System Properties Environment Variables likes this;
C:\Program Files\Java\jdk1.7
How to configure jboss-eap 6.2 as a service and set Auto-start on CentOS 6.x and Linux1 AMI
Follow the below steps to Configure Jboss6.2 as Service and configure it as Auto restart. The process is same for CentOS 6.x and AWS Linux1 AMI.
- Copy files into system directories
a. Copy the modified configuration file to the /etc/jboss-as directory.
mkdir /etc/jboss-as
cp /var/lib/jboss-eap-6.2/bin/init.d/jboss-as.conf /etc/jboss-as/
Uncomment following line
JBOSS_USER=root
and add the following line at the end of this file.
export JBOSS_USER
b. Copy the start-up script to the /etc/init.d directory.
cp /var/lib/jboss-eap-6.2/bin/init.d/jboss-as-standalone.sh /etc/init.d/jboss-62
Do following changes in /etc/init.d/jboss-62 file
i)-Set Java Home
JAVA_HOME=/usr/java/jdk1.7.0_60 export JAVA_HOME
ii)-Set JBOSS Home
JBOSS_HOME=/var/lib/jboss-eap-6.2 export JBOSS_HOME
iii)-Change Configuration xml file name(you may give what ever configuration file name you are using)
JBOSS_CONFIG=standalone-full.xml
iv)-Add "-b 0.0.0.0 -bmanagement 0.0.0.0" in the following line, so that binding is set for every IP address on this system
daemon --user $JBOSS_USER LAUNCH_JBOSS_IN_BACKGROUND=1
JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT -b 0.0.0.0 -bmanagement
0.0.0.0 -c $JBOSS_CONFIG 2>&1 > $JBOSS_CONSOLE_LOG &
Add the start-up script as a service.
Add the new jboss-as-standalone.sh ( i.e jboss-62 ) service to list of automatically started services, using the chkconfig command.
chkconfig --add jboss-62
Start the service.
service jboss-62 start
Make the service to start automatically when you restart your
server.chkconfig jboss-62 on
Restart the service
service jboss-62 restart
Now Jboss6.2 configuration as a Service as Auto restart is complete.
Reboot os and check that service is running. Run below command ot verify that service is running on port 8080
netstat -aptn | grep LISTEN | grep 8080
Related Topics
Aws Lambda Permission Denied When Trying to Use Ffmpeg
What Does a Hexadecimal Number, with a Register in Parenthesis Mean in Assembly
Linux Why Can't I Pipe Find Result to Rm
Setting a Gdb Exit Breakpoint Not Working
Http Debugging Proxy for Linux and MAC
How to Deploy a Container into a Specific Node in a Docker Swarm
Linux Bash: Setting Iptables Rules to Allow Both Active and Passive Ftp
Parallel Make: Set -J8 as The Default Option
When "Vagrant Up" It Says "It Appears Your Machine Doesn't Support Nfs" (Debian Jessie)
Platform Independent Resource Management
How to Filter Data Between 2 Dates with Awk in a Bash Script
How to Paste Multi-Line Bash Codes into Terminal and Run It All at Once
Walking Page Tables of a Process in Linux
Unix: Differencebetween Source and Export
What Is the *Nix Command to View a User's Default Login Shell