chore(bin/emqx): Do not rely on beam.smp program name
This commit is contained in:
parent
730d09f874
commit
cf23d9efe9
|
@ -127,7 +127,7 @@ running_test(){
|
||||||
IDLE_TIME=$((IDLE_TIME+1))
|
IDLE_TIME=$((IDLE_TIME+1))
|
||||||
done
|
done
|
||||||
pytest -v /paho-mqtt-testing/interoperability/test_client/V5/test_connect.py::test_basic
|
pytest -v /paho-mqtt-testing/interoperability/test_client/V5/test_connect.py::test_basic
|
||||||
emqx stop || kill $(ps -ef |grep emqx | grep beam.smp |awk '{print $2}')
|
emqx stop || kill $(ps -ef | grep -E '\-progname\s.+emqx\s' |awk '{print $2}')
|
||||||
|
|
||||||
if [ $(sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g' | sed 's/"//g') = ubuntu ] \
|
if [ $(sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g' | sed 's/"//g') = ubuntu ] \
|
||||||
|| [ $(sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g' | sed 's/"//g') = debian ] \
|
|| [ $(sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g' | sed 's/"//g') = debian ] \
|
||||||
|
|
|
@ -11,8 +11,8 @@ services:
|
||||||
- "EMQX_CLUSTER__STATIC__SEEDS=emqx@node1.emqx.io, emqx@node2.emqx.io"
|
- "EMQX_CLUSTER__STATIC__SEEDS=emqx@node1.emqx.io, emqx@node2.emqx.io"
|
||||||
- "EMQX_ZONE__EXTERNAL__RETRY_INTERVAL=2s"
|
- "EMQX_ZONE__EXTERNAL__RETRY_INTERVAL=2s"
|
||||||
- "EMQX_MQTT__MAX_TOPIC_ALIAS=10"
|
- "EMQX_MQTT__MAX_TOPIC_ALIAS=10"
|
||||||
command:
|
command:
|
||||||
- /bin/sh
|
- /bin/sh
|
||||||
- -c
|
- -c
|
||||||
- |
|
- |
|
||||||
sed -i "s 127.0.0.1 $$(ip route show |grep "link" |awk '{print $$1}') g" /opt/emqx/etc/acl.conf
|
sed -i "s 127.0.0.1 $$(ip route show |grep "link" |awk '{print $$1}') g" /opt/emqx/etc/acl.conf
|
||||||
|
@ -27,7 +27,7 @@ services:
|
||||||
emqx-bridge:
|
emqx-bridge:
|
||||||
aliases:
|
aliases:
|
||||||
- node1.emqx.io
|
- node1.emqx.io
|
||||||
|
|
||||||
emqx2:
|
emqx2:
|
||||||
container_name: node2.emqx.io
|
container_name: node2.emqx.io
|
||||||
image: emqx/emqx:build-alpine-amd64
|
image: emqx/emqx:build-alpine-amd64
|
||||||
|
@ -38,8 +38,8 @@ services:
|
||||||
- "EMQX_CLUSTER__STATIC__SEEDS=emqx@node1.emqx.io, emqx@node2.emqx.io"
|
- "EMQX_CLUSTER__STATIC__SEEDS=emqx@node1.emqx.io, emqx@node2.emqx.io"
|
||||||
- "EMQX_ZONE__EXTERNAL__RETRY_INTERVAL=2s"
|
- "EMQX_ZONE__EXTERNAL__RETRY_INTERVAL=2s"
|
||||||
- "EMQX_MQTT__MAX_TOPIC_ALIAS=10"
|
- "EMQX_MQTT__MAX_TOPIC_ALIAS=10"
|
||||||
command:
|
command:
|
||||||
- /bin/sh
|
- /bin/sh
|
||||||
- -c
|
- -c
|
||||||
- |
|
- |
|
||||||
sed -i "s 127.0.0.1 $$(ip route show |grep "link" |awk '{print $$1}') g" /opt/emqx/etc/acl.conf
|
sed -i "s 127.0.0.1 $$(ip route show |grep "link" |awk '{print $$1}') g" /opt/emqx/etc/acl.conf
|
||||||
|
|
23
bin/emqx
23
bin/emqx
|
@ -246,15 +246,11 @@ if [ -z "$RELX_CONFIG_PATH" ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract the target node name from node.args
|
|
||||||
if [ -z "$NAME_ARG" ]; then
|
if [ -z "$NAME_ARG" ]; then
|
||||||
if [ ! -z "$EMQX_NODE_NAME" ]; then
|
NODENAME="${EMQX_NODE_NAME:-}"
|
||||||
NODENAME="$EMQX_NODE_NAME"
|
# check if there is a node running, inspect its name
|
||||||
elif [ ! -z `ps -ef | grep "$ERTS_PATH/beam.smp" | grep -o -E '\-name (\S*)' | awk '{print $2}'` ]; then
|
[ -z "$NODENAME" ] && NODENAME=`ps -ef | grep -E '\-progname\s.*emqx\s' | grep -o -E '\-name (\S*)' | awk '{print $2}'`
|
||||||
NODENAME=`ps -ef | grep "$ERTS_PATH/beam.smp" | grep -o -E '\-name (\S*)' | awk '{print $2}'`
|
[ -z "$NODENAME" ] && NODENAME=`egrep '^[ \t]*node.name[ \t]*=[ \t]*' "$RUNNER_ETC_DIR/emqx.conf" 2> /dev/null | tail -1 | cut -d = -f 2-`
|
||||||
else
|
|
||||||
NODENAME=`egrep '^[ \t]*node.name[ \t]*=[ \t]*' "$RUNNER_ETC_DIR/emqx.conf" 2> /dev/null | tail -1 | cut -d = -f 2-`
|
|
||||||
fi
|
|
||||||
if [ -z "$NODENAME" ]; then
|
if [ -z "$NODENAME" ]; then
|
||||||
echoerr "vm.args needs to have a -name parameter."
|
echoerr "vm.args needs to have a -name parameter."
|
||||||
echoerr " -sname is not supported."
|
echoerr " -sname is not supported."
|
||||||
|
@ -273,13 +269,10 @@ PIPE_DIR="${PIPE_DIR:-/$RUNNER_DATA_DIR/${WHOAMI}_erl_pipes/$NAME/}"
|
||||||
|
|
||||||
# Extract the target cookie
|
# Extract the target cookie
|
||||||
if [ -z "$COOKIE_ARG" ]; then
|
if [ -z "$COOKIE_ARG" ]; then
|
||||||
if [ ! -z "$EMQX_NODE_COOKIE" ]; then
|
COOKIE="${EMQX_NODE_COOKIE:-}"
|
||||||
COOKIE="$EMQX_NODE_COOKIE"
|
# check if there is a node running, steal its cookie
|
||||||
elif [ ! -z `ps -ef | grep "$ERTS_PATH/beam.smp" | grep -o -E '\-setcookie (\S*)' | awk '{print $2}'` ]; then
|
[ -z "$COOKIE" ] && COOKIE=`ps -ef | grep -E '\-progname\s.*emqx\s' | grep -o -E '\-setcookie (\S*)' | awk '{print $2}'`
|
||||||
COOKIE=`ps -ef | grep "$ERTS_PATH/beam.smp" | grep -o -E '\-setcookie (\S*)' | awk '{print $2}'`
|
[ -z "$COOKIE" ] && COOKIE=`egrep '^[ \t]*node.cookie[ \t]*=[ \t]*' "$RUNNER_ETC_DIR/emqx.conf" 2> /dev/null | tail -1 | cut -d = -f 2-`
|
||||||
else
|
|
||||||
COOKIE=`egrep '^[ \t]*node.cookie[ \t]*=[ \t]*' "$RUNNER_ETC_DIR/emqx.conf" 2> /dev/null | tail -1 | cut -d = -f 2-`
|
|
||||||
fi
|
|
||||||
if [ -z "$COOKIE" ]; then
|
if [ -z "$COOKIE" ]; then
|
||||||
echoerr "vm.args needs to have a -setcookie parameter."
|
echoerr "vm.args needs to have a -setcookie parameter."
|
||||||
echoerr "please check $RUNNER_ETC_DIR/emqx.conf"
|
echoerr "please check $RUNNER_ETC_DIR/emqx.conf"
|
||||||
|
|
25
bin/emqx_ctl
25
bin/emqx_ctl
|
@ -31,19 +31,15 @@ relx_nodetool() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Extract the target node name from node.args
|
|
||||||
if [ -z "$NAME_ARG" ]; then
|
if [ -z "$NAME_ARG" ]; then
|
||||||
if [ ! -z "$EMQX_NODE_NAME" ]; then
|
NODENAME="${EMQX_NODE_NAME:-}"
|
||||||
NODENAME="$EMQX_NODE_NAME"
|
# check if there is a node running, inspect its name
|
||||||
elif [ ! -z `ps -ef | grep "$ERTS_PATH/beam.smp" | grep -o -E '\-name (\S*)' | awk '{print $2}'` ]; then
|
[ -z "$NODENAME" ] && NODENAME=`ps -ef | grep -E '\progname\s.*emqx\s' | grep -o -E '\-name (\S*)' | awk '{print $2}'`
|
||||||
NODENAME=`ps -ef | grep "$ERTS_PATH/beam.smp" | grep -o -E '\-name (\S*)' | awk '{print $2}'`
|
[ -z "$NODENAME" ] && NODENAME=`egrep '^[ \t]*node.name[ \t]*=[ \t]*' "$RUNNER_ETC_DIR/emqx.conf" 2> /dev/null | tail -1 | cut -d = -f 2-`
|
||||||
else
|
|
||||||
NODENAME=`egrep '^[ \t]*node.name[ \t]*=[ \t]*' $RUNNER_ETC_DIR/emqx.conf 2> /dev/null | tail -1 | cut -d = -f 2-`
|
|
||||||
fi
|
|
||||||
if [ -z "$NODENAME" ]; then
|
if [ -z "$NODENAME" ]; then
|
||||||
echoerr "vm.args needs to have a -name parameter."
|
echoerr "vm.args needs to have a -name parameter."
|
||||||
echoerr " -sname is not supported."
|
echoerr " -sname is not supported."
|
||||||
echoerr "please check $RUNNER_ETC_DIR/emqx.conf"
|
echoerr "perhaps you do not have read permissions on $RUNNER_ETC_DIR/emqx.conf"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
NAME_ARG="-name ${NODENAME# *}"
|
NAME_ARG="-name ${NODENAME# *}"
|
||||||
|
@ -56,13 +52,10 @@ NAME="$(echo "$NAME_ARG" | awk '{print $2}')"
|
||||||
|
|
||||||
# Extract the target cookie
|
# Extract the target cookie
|
||||||
if [ -z "$COOKIE_ARG" ]; then
|
if [ -z "$COOKIE_ARG" ]; then
|
||||||
if [ ! -z "$EMQX_NODE_COOKIE" ]; then
|
COOKIE="${EMQX_NODE_COOKIE:-}"
|
||||||
COOKIE="$EMQX_NODE_COOKIE"
|
# check if there is a node running, steal its cookie
|
||||||
elif [ ! -z `ps -ef | grep "$ERTS_PATH/beam.smp" | grep -o -E '\-setcookie (\S*)' | awk '{print $2}'` ]; then
|
[ -z "$COOKIE" ] && COOKIE=`ps -ef | grep -E '\-progname\s.*emqx\s' | grep -o -E '\-setcookie (\S*)' | awk '{print $2}'`
|
||||||
COOKIE=`ps -ef | grep "$ERTS_PATH/beam.smp" | grep -o -E '\-setcookie (\S*)' | awk '{print $2}'`
|
[ -z "$COOKIE" ] && COOKIE=`egrep '^[ \t]*node.cookie[ \t]*=[ \t]*' "$RUNNER_ETC_DIR/emqx.conf" 2> /dev/null | tail -1 | cut -d = -f 2-`
|
||||||
else
|
|
||||||
COOKIE=`egrep '^[ \t]*node.cookie[ \t]*=[ \t]*' $RUNNER_ETC_DIR/emqx.conf 2> /dev/null | tail -1 | cut -d = -f 2-`
|
|
||||||
fi
|
|
||||||
if [ -z "$COOKIE" ]; then
|
if [ -z "$COOKIE" ]; then
|
||||||
echoerr "vm.args needs to have a -setcookie parameter."
|
echoerr "vm.args needs to have a -setcookie parameter."
|
||||||
echoerr "please check $RUNNER_ETC_DIR/emqx.conf"
|
echoerr "please check $RUNNER_ETC_DIR/emqx.conf"
|
||||||
|
|
|
@ -38,7 +38,7 @@ status -p $pidfile -l $(basename $lockfile) $NAME >/dev/null 2>&1
|
||||||
running=$?
|
running=$?
|
||||||
|
|
||||||
find_pid() {
|
find_pid() {
|
||||||
ps ax | grep beam.smp | grep -E "\-progname.+$NAME" | awk '{print $1}'
|
ps ax | grep -E "\-progname.+$NAME" | awk '{print $1}'
|
||||||
}
|
}
|
||||||
|
|
||||||
check_pid_status() {
|
check_pid_status() {
|
||||||
|
@ -92,7 +92,7 @@ stop() {
|
||||||
|
|
||||||
hardstop() {
|
hardstop() {
|
||||||
echo -n $"Shutting down $NAME: "
|
echo -n $"Shutting down $NAME: "
|
||||||
su - emqx -c "ps -ef | grep beam.smp | grep '\-progname $NAME ' | grep -v grep | awk '{print \$2}' | xargs kill -9"
|
su - emqx -c "ps -ef | grep '\-progname $NAME ' | grep -v grep | awk '{print \$2}' | xargs kill -9"
|
||||||
for n in $(seq 1 10); do
|
for n in $(seq 1 10); do
|
||||||
sleep 1
|
sleep 1
|
||||||
check_pid_status
|
check_pid_status
|
||||||
|
|
Loading…
Reference in New Issue