Unix

Application Server as a Service in Unix

Running the Application Server as a service or daemon on the machine ensures that service restart automatically when the machine reboots and also provides the capability to start the server with a UNIX shell.

In this post, we will create Weblogic  server as a service making it to start at machine reboot in few steps as follows:

Step 1: Create a file to configure the init script with name weblogic inside directory /etc/default/ with content, as follows:

# /etc/default/weblogic script used to configure the init script

# Weblogic Server installation home directory
WLSHOME="/opt/weblogic/wlserver_10.3"

# Weblogic Server sample server
SAMPLESERVER="/samples/domains/wl_server"

# Username password for stopping
USER="weblogic"
PASSWORD="welcome1"

Step 2: Create a file with name weblogic inside directory /etc/init.d/ with content, as follows:

#!/bin/sh

. /etc/default/weblogic

start() {
  ${WLSHOME}${SAMPLESERVER}/bin/startWebLogic.sh &
}

stop() {
  ${WLSHOME}${SAMPLESERVER}/bin/stopWebLogic.sh -username ${USER} -password ${PASSWORD} &
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac

Step 3: Make weblogic file inside directory /etc/init.d/ as executable

$ cd /etc/init.d/
$ chmod +x weblogic

Step 4: Add the service to the automatic startup system.

$ sudo update-rc.d weblogic defaults
Reference: Application Server as a Service in Unix from our SCG partner Arpit Aggarwal at the Arpit Aggarwal blog.

Arpit Aggarwal

Arpit is a Consultant at Xebia in India. He has been designing and building J2EE applications since more than 4 years. He is fond of Object Oriented and lover of Functional programming and his specialties are Java, J2EE, Scala, SOA, Cloud and Big Data Technologies.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Raghavan alias Saravanan Muthu

Good tip Arpit.

Back to top button