WAS does not seem to install any default init scripts, so I created one. You can configure it to start and stop multiple application servers by listing them all in the APPSERVERS variable (separated by spaces).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
#!/bin/sh # chkconfig: 35 99 10 # description: Starts and stops Websphere Application Server . /lib/lsb/init-functions # Please edit these variables to match your environment. You may list one or more # application servers separated by spaces in the APPSERVERS variable. OWNER=wasadmin USERNAME=wasuser PASSWORD=secret APPSERVERS="Appserver1" WASDIR=/opt/WebSphere/AppServer DMGRDIR=/opt/WebSphere/DeploymentManager LOCKDIR=/var/lock/subsys DMGRLOCK="$LOCKDIR/WAS_deploymentmgr" NODEAGENTLOCK="$LOCKDIR/WAS_nodeagent" # Don't edit beyond this point. start_dmgr() { MSG="Starting WAS Deployment Manager" [[ ! -e $DMGRLOCK ]] \ && su - $OWNER -c "$DMGRDIR/bin/startManager.sh -user $USERNAME -password $PASSWORD" \ && touch $DMGRLOCK \ && log_success_msg $MSG \ || log_failure_msg $MSG } stop_dmgr() { MSG="Stopping WAS Deployment Manager" [[ -e $DMGRLOCK ]] \ && [[ -e "$DMGRDIR/bin/stopManager.sh" ]] \ && su - $OWNER -c "$DMGRDIR/bin/stopManager.sh -user $USERNAME -password $PASSWORD" \ && rm -f $DMGRLOCK \ && log_success_msg $MSG \ || log_failure_msg $MSG } start_nodeagent() { MSG="Starting WAS Node Agent" [[ ! -e $NODEAGENTLOCK ]] \ && su - $OWNER -c "$WASDIR/bin/startNode.sh -user $USERNAME -password $PASSWORD" \ && touch $NODEAGENTLOCK \ && log_success_msg $MSG \ || log_failure_msg $MSG } stop_nodeagent() { MSG="Starting WAS Node Agent" [[ -e $NODEAGENTLOCK ]] \ && su - $OWNER -c "$WASDIR/bin/stopNode.sh -user $USERNAME -password $PASSWORD" \ && rm -f $NODEAGENTLOCK \ && log_success_msg $MSG \ || log_failure_msg $MSG } start_appservers() { for WAS in $APPSERVERS do MSG="Starting WAS: $WAS" LOCK="$LOCKDIR/WAS_$WAS" [[ ! -e $LOCK ]] \ && su - $OWNER -c "$WASDIR/bin/startServer.sh $WAS -user $USERNAME -password $PASSWORD" \ && touch $LOCK \ && log_success_msg $MSG \ || log_failure_msg $MSG done } stop_appservers() { for WAS in $APPSERVERS do MSG="Stopping WAS: $WAS" LOCK="$LOCKDIR/WAS_$WAS" [[ -e $LOCK ]] \ && su - $OWNER -c "$WASDIR/bin/stopServer.sh $WAS -user $USERNAME -password $PASSWORD" \ && rm -f $LOCK \ && log_success_msg $MSG \ || log_failure_msg $MSG done } case "$1" in 'start') [[ -e "$DMGRDIR/bin/startManager.sh" ]] && start_dmgr start_nodeagent start_appservers ;; 'stop') stop_appservers stop_nodeagent [[ -e "$DMGRDIR/bin/startManager.sh" ]] && stop_dmgr ;; 'restart') stop_appservers stop_nodeagent [[ -e "$DMGRDIR/bin/startManager.sh" ]] && stop_dmgr sleep 5 [[ -e "$DMGRDIR/bin/startManager.sh" ]] && start_dmgr start_nodeagent start_appservers ;; 'status') [[ -e $DMGRLOCK ]] \ && echo WAS Deployment Manager is running (lockfile $DMGRLOCK) \ || echo WAS Deployment Manager is stopped (no lockfile) [[ -e $NODEAGENTLOCK ]] && echo WAS Node Agent is running (lockfile $NODEAGENTLOCK) \ || echo WAS Node Agent is stopped (no lockfile) for WAS in $APPSERVERS do LOCK="$LOCKDIR/WAS_$WAS" [[ -e $LOCK ]] \ && echo WAS $WAS is running (lockfile $LOCK) \ || echo WAS $WAS is stopped (no lockfile) done $WASDIR/bin/serverStatus.sh -all -user $USERNAME -password $PASSWORD ;; *) echo "Usage: was (start|stop|restart|status)" exit 1 ;; esac |