-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwildfly
executable file
·148 lines (121 loc) · 3.56 KB
/
wildfly
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#! /bin/bash
#
# JBoss Control Script
#
# To use this script run it as root - it will switch to the specified user
#
# Here is a little (and extremely primitive) startup/shutdown script
# for RedHat systems. It assumes that JBoss lives in /usr/local/jboss,
# it's run by user 'jboss' and JDK binaries are in /usr/local/jdk/bin.
# All this can be changed in the script itself.
#
# Either modify this script for your requirements or just ensure that
# the following variables are set correctly before calling the script.
# Init script modified for Ubuntu Server 8.04 by
# Chiral Software, Inc.
# To install make symlink in /etc/init.d and sudo update-rc.d jboss defaults
# source local environment
SCRIPT_DIR="$(dirname "$(readlink -f ${BASH_SOURCE[0]})")"
export WILDFLY_HOME=$SCRIPT_DIR/wildfly-8.2.0.Final
#define the user under which jboss will run, or use 'RUNASIS' to run as the current user
WILDFLY_USER=${WILDFLY_USER:-"enav"}
#server config file
SERVER_CONFIG="standalone.xml"
#define the script to use to start jboss
WILDFLYSH=${WILDFLYSH:-"$WILDFLY_HOME/bin/standalone.sh -b=0.0.0.0 -bmanagement=0.0.0.0 --server-config $SERVER_CONFIG"}
#define the script to use to stop jboss
WILDFLYSTOP="$WILDFLY_HOME/bin/jboss-cli.sh --connect command=:shutdown"
if [ "$WILDFLY_USER" = "$USER" ]; then
SUBIT=""
else
SUBIT="su - $WILDFLY_USER -c "
fi
if [ -n "$WILDFLY_CONSOLE" -a ! -d "$WILDFLY_CONSOLE" ]; then
# ensure the file exists
touch $WILDFLY_CONSOLE
if [ ! -z "$SUBIT" ]; then
chown $WILDFLY_USER $WILDFLY_CONSOLE
fi
fi
if [ -n "$WILDFLY_CONSOLE" -a ! -f "$WILDFLY_CONSOLE" ]; then
echo "WARNING: location for saving console log invalid: $WILDFLY_CONSOLE"
echo "WARNING: ignoring it and using /dev/null"
WILDFLY_CONSOLE="/dev/null"
fi
#define what will be done with the console log
WILDFLY_CONSOLE=${WILDFLY_CONSOLE:-"/dev/null"}
WILDFLY_CMD_START="cd $WILDFLY_HOME/bin; $WILDFLYSH"
if [ ! -d "$WILDFLY_HOME" ]; then
echo WILDFLY_HOME does not exist as a valid directory : $WILDFLY_HOME
exit 1
fi
procrunning () {
procid=0
for procid in `pidof -x $WILDFLY_HOME/bin/standalone.sh`; do
ps -fp $procid | grep "${WILDFLYSH% *}" > /dev/null && pid=$procid
done
}
stop () {
pid=0
procrunning
if [ $pid = '0' ]; then
/bin/echo -n -e "\nNo JBossas is currently running\n"
exit 1
fi
RETVAL=1
# If process is still running
# Try to use client to shutdown
if [ -z "$SUBIT" ]; then
$WILDFLYSTOP
else
$SUBIT "$WILDFLYSTOP"
fi
sleep 5
# Second, try to kill it nicely
for id in `ps --ppid $pid | awk '{print $1}' | grep -v "^PID$"`; do
if [ -z "$SUBIT" ]; then
kill -15 $id
else
$SUBIT "kill -15 $id"
fi
done
sleep=0
while [ $sleep -lt 120 -a $RETVAL -eq 1 ]; do
/bin/echo -n -e "\nwaiting for JBoss processes to stop";
sleep 10
sleep=`expr $sleep + 10`
pid=0
procrunning
if [ $pid = '0' ]; then
RETVAL=0
fi
done
count=0
pid=0
procrunning
if [ $RETVAL != 0 ] ; then
/bin/echo -e "\nTimeout: Shutdown command was sent, but process is still running with PID $pid"
exit 1
fi
echo
exit 0
}
case "$1" in
start)
cd $WILDFLY_HOME/bin
if [ -z "$SUBIT" ]; then
eval $WILDFLY_CMD_START >${WILDFLY_CONSOLE} 2>&1 &
else
$SUBIT "$WILDFLY_CMD_START >${WILDFLY_CONSOLE} 2>&1 &"
fi
;;
stop)
stop
;;
restart)
$0 stop
$0 start
;;
*)
echo "usage: $0 (start|stop|restart|help)"
esac