Link to home
Start Free TrialLog in
Avatar of BILL Carlisle
BILL CarlisleFlag for United States of America

asked on

AIX - Can you verify my assumption? Create Script for Service (daemon)

Hi All,

This is my understanding to start glassfish4 as a service (or daemon) on AIX

$ vi /etc/rc.d/rc2.d

Enter the following:

#!bin/bash
# description: Glassfish Start Stop Restart
# processname: glassfish
# chkconfig: 234 20 80
export JAVA_HOME=/usr/java71
PATH=$JAVA_HOME/bin:$PATH
export PATH
GLASSFISH_HOME=/u01/oracle/glassfish/glassfish
GLASSFISH_USER=glassfsh

case $1 in
start)
su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin start-domain domain1"
;;
stop)
su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin stop-domain domain1"
;;
restart)
su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin stop-domain domain1"
su $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin start-domain domain1"
;;
esac
exit 0 

Open in new window


Thank you in advance,
Bill
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BILL Carlisle

ASKER

Hi N,

Ok, wouldn't you just
vi /etc/rc.d/init.d

#!/bin/ksh
# description: Glassfish Start Stop Restart
# processname: glassfish
# 
export JAVA_HOME=/usr/java71
PATH=$JAVA_HOME/bin:$PATH
export PATH
GLASSFISH_HOME=/u01/oracle/glassfish/glassfish
GLASSFISH_USER=glassfsh

case $1 in
start)
su - $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin start-domain domain1"
;;
stop)
su - $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin stop-domain domain1"
;;
restart)
su - $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin stop-domain domain1"
su - $GLASSFISH_USER -c "$GLASSFISH_HOME/bin/asadmin start-domain domain1"
;;
esac
exit 0

Open in new window


paste the below script into it (i for insert), then save (:wq)

To "create softlinks" - just looked it up.. :)
ln -s S11_Glassfish /etc/rc.d/rc2.d

you may need to explain a bit more on the links?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Awesome, so to test it
So on reboot of the server it automatically executes

/etc/rc.d/init.d/glassfish K11glassfish stop

/etc/rc.d/init.d/glassfish S11glassfish start

I don't have to do anything else?

I tested it this way:

# /etc/rc.d/init.d/glassfish restart
[YOU HAVE NEW MAIL]
Waiting for the domain to stop .
Command stop-domain executed successfully.
[YOU HAVE NEW MAIL]
Waiting for domain1 to start ........................
Successfully started the domain : domain1
domain  Location: /u01/oracle/glassfish/glassfish/domains/domain1
Log File: /u01/oracle/glassfish/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.

and tried to test this way:
/etc/rc.d/init.d/glassfish K11glassfish stop

then I tried the GlassFish Admin - but the admin worked, wasn't stopped
Is the only wat to test it by actually rebooting the server?

Thanks N!
Bill
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ohhh I got it.. ya duh,

/etc/rc.d/rc2.d/K11glassfish
is like an alias (link, duh)

to
/etc/rc.d/init.d/glassfish

so
/etc/rc.d/rc2.d/K11glassfish stop
should do it!

and it did:

# /etc/rc.d/rc2.d/K11glassfish stop
[YOU HAVE NEW MAIL]
Waiting for the domain to stop .
Command stop-domain executed successfully.
# /etc/rc.d/rc2.d/S11glassfish start
[YOU HAVE NEW MAIL]
Waiting for domain1 to start ...............
Successfully started the domain : domain1
domain  Location: /u01/oracle/glassfish/glassfish/domains/domain1
Log File: /u01/oracle/glassfish/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.

Open in new window

Whoopee! Fine!
you are the man! I'll close this.. thx again!
Thx for the points!

A little side note:

The "K" and "S" prefixes are only for AIX to know which parameter to pass to the script.

So

/etc/rc.d/rc2.d/S11glassfish stop
/etc/rc.d/rc2.d/K11glassfish start

issued from the command line would also work, counter-intuitevely!

N
Thanks makes sense now!