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
|
#!/bin/sh
# Start/stop/restart wildfly.
# Copyright 2014 Giorgio Peron, Campodarsego, PD, Italy giorgio.peron@gmail.com
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# define where wildfly is - this is the directory containing directories log, bin, conf etc
WILDFLY_HOME=${WILDFLY_HOME:-"/usr/share/wildfly"}
# make java is on your path
JAVAPTH=${JAVAPTH:-"$JAVA_HOME/bin"}
# define the user under which wildfly will run, or use RUNASIS to run as the current user
WILDFLYUS=${WILDFLYUS:-"wildfly"}
export LAUNCH_WILDFLY_IN_BACKGROUND=yes
# define the script to use to start standalone wildfly
WILDFLY_START_STANDALONE=${WILDFLY_START_STANDALONE:-"$WILDFLY_HOME/bin/standalone.sh "}
# define the script to use to shutdown wildfly
# change host and port as need
WILDFLY_STOP_STANDALONE=${WILDFLY_STOP_STANDALONE:-"$WILDFLY_HOME/bin/jboss-cli.sh --connect controller=127.0.0.1:9999 command=:shutdown"}
# define log file
WILDFLY_CONSOLE="/var/log/wildfly/wildfly.log"
WILDFLY_DOMAIN_CONSOLE="/var/log/wildfly/wildfly_domain.log"
if [ -n "$WILDFLY_CONSOLE" -a ! -d "$WILDFLY_CONSOLE" ]; then
# ensure the file exists
touch $WILDFLY_CONSOLE
if [ "$WILDFLYUS" != "RUNASIS" ]; then
chown -R $WILDFLYUS.$WILDFLYUS $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"}
if [ -n "$WILDFLY_DOMAIN_CONSOLE" -a ! -d "$WILDFLY_DOMAIN_CONSOLE" ]; then
# ensure the file exists
touch $WILDFLY_DOMAIN_CONSOLE
if [ "$WILDFLYUS" != "RUNASIS" ]; then
chown -R $WILDFLYUS.$WILDFLYUS $WILDFLY_DOMAIN_CONSOLE
fi
fi
if [ -n "$WILDFLY_DOMAIN_CONSOLE" -a ! -f "$WILDFLY_DOMAIN_CONSOLE" ]; then
echo "WARNING: location for saving console log invalid: $WILDFLY_DOMAIN_CONSOLE"
echo "WARNING: ignoring it and using /dev/null"
WILDFLY_DOMAIN_CONSOLE="/dev/null"
fi
# define what will be done with the console log
WILDFLY_DOMAIN_CONSOLE=${WILDFLY_DOMAIN_CONSOLE:-"/dev/null"}
CMD_START_STANDALONE="cd $WILDFLY_HOME/bin; $WILDFLY_START_STANDALONE"
CMD_STOP_STANDALONE="cd $WILDFLY_HOME/bin; $WILDFLY_STOP_STANDALONE"
if [ "$WILDFLYUS" = "RUNASIS" ]; then
SUBIT=""
else
SUBIT="su $WILDFLYUS -c "
fi
if [ -z "`echo $PATH | grep $JAVAPTH`" ]; then
export PATH=$PATH:$JAVAPTH
fi
if [ ! -d "$WILDFLY_HOME" ]; then
echo "WILDFLY_HOME does not exist as a valid directory : $WILDFLY_HOME"
exit 1
fi
case "$1" in
start)
echo "Starting WildFly Application Server"
cd $WILDFLY_HOME/bin
if [ -z "$SUBIT" ]; then
eval $CMD_START_STANDALONE >${WILDFLY_CONSOLE} 2>&1 &
else
$SUBIT "$CMD_START_STANDALONE >${WILDFLY_CONSOLE} 2>&1 &"
fi
;;
stop)
echo "Stopping WildFly Application Server"
if [ -z "$SUBIT" ]; then
$CMD_STOP_STANDALONE >/dev/null 2>&1
else
$SUBIT "$CMD_STOP_STANDALONE >/dev/null 2>&1"
fi
;;
restart)
$0 stop
$0 start
;;
domain-start)
echo "Starting Domain WildFly Application Server"
cd $WILDFLY_HOME/bin
if [ -z "$SUBIT" ]; then
eval $CMD_START_DOMAIN >${WILDFLY_DOMAIN_CONSOLE} 2>&1 &
else
$SUBIT "$CMD_START_DOMAIN >${WILDFLY_DOMAIN_CONSOLE} 2>&1 &"
fi
;;
domain-stop)
echo "Stopping Domain WildFly Application Server"
if [ -z "$SUBIT" ]; then
$CMD_STOP_DOMAIN >/dev/null 2>&1
else
$SUBIT "$CMD_STOP_DOMAIN >/dev/null 2>&1"
fi
;;
domain-restart)
$0 domain-stop
$0 domain-start
;;
*)
echo "usage: $0 (start|stop|restart|help|domain-start|domain-stop|domain-restart)"
esac
|