- make cowboy correctly parse target URI that has method in uppercase;

- sbin/leofs script improvements: on start wait for a node to begin
  responding to ping, white-space cleanup;
- rc script cleanup.
This commit is contained in:
Mikolaj Golub 2014-08-01 19:02:54 +00:00
parent eb9f4ce133
commit c54c93b42c
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=363753
4 changed files with 76 additions and 43 deletions

View file

@ -3,7 +3,7 @@
PORTNAME= leofs PORTNAME= leofs
PORTVERSION= 1.0.2 PORTVERSION= 1.0.2
PORTREVISION= 1 PORTREVISION= 2
CATEGORIES= databases CATEGORIES= databases
MAINTAINER= trociny@FreeBSD.org MAINTAINER= trociny@FreeBSD.org

View file

@ -13,7 +13,7 @@
# leofs_servers (list): Specify servers to run as a space separated # leofs_servers (list): Specify servers to run as a space separated
# list of possible values: # list of possible values:
# gateway, # gateway,
# manager_master, # manager,
# manager_slave, # manager_slave,
# storage. # storage.
# The aliase ALL may be used to run all servers. # The aliase ALL may be used to run all servers.
@ -53,7 +53,7 @@ leofs_start()
local s local s
for s in ${leofs_servers}; do for s in ${leofs_servers}; do
echo -n "Starting ${s}... " echo -n "Starting leofs ${s}... "
%%PREFIX%%/sbin/leofs ${s} start %%PREFIX%%/sbin/leofs ${s} start
if [ $? = 0 ]; then if [ $? = 0 ]; then
echo "done." echo "done."
@ -70,7 +70,7 @@ leofs_stop()
local status=0 local status=0
for s in ${leofs_servers}; do for s in ${leofs_servers}; do
echo -n "Stopping ${s}... " echo -n "Stopping leofs ${s}... "
%%PREFIX%%/sbin/leofs ${s} stop %%PREFIX%%/sbin/leofs ${s} stop
if [ $? = 0 ]; then if [ $? = 0 ]; then
echo "done." echo "done."
@ -89,10 +89,10 @@ leofs_status()
for s in ${leofs_servers}; do for s in ${leofs_servers}; do
%%PREFIX%%/sbin/leofs ${s} ping > /dev/null 2>&1 %%PREFIX%%/sbin/leofs ${s} ping > /dev/null 2>&1
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo "${s} is not running." echo "leofs ${s} is not running."
status=1 status=1
else else
echo "${s} is running." echo "leofs ${s} is running."
fi fi
done done
@ -114,7 +114,7 @@ for s in ${leofs_servers}; do
gateway|manager|manager_slave|storage) gateway|manager|manager_slave|storage)
;; ;;
*) *)
warn "unknown leo server: ${s}" warn "unknown leofs server: ${s}"
exit 1 exit 1
;; ;;
esac esac

View file

@ -0,0 +1,17 @@
Make cowboy correctly parse target URI that has method in uppercase.
--- deps/cowboy/src/cowboy_protocol.erl.orig 2013-06-20 19:44:36.000000000 +0300
+++ deps/cowboy/src/cowboy_protocol.erl 2014-07-31 23:10:11.000000000 +0300
@@ -214,8 +214,12 @@
parse_version(Rest, State, Method, <<"*">>, <<>>);
parse_uri(<< "http://", Rest/bits >>, State, Method) ->
parse_uri_skip_host(Rest, State, Method);
+parse_uri(<< "HTTP://", Rest/bits >>, State, Method) ->
+ parse_uri_skip_host(Rest, State, Method);
parse_uri(<< "https://", Rest/bits >>, State, Method) ->
parse_uri_skip_host(Rest, State, Method);
+parse_uri(<< "HTTPS://", Rest/bits >>, State, Method) ->
+ parse_uri_skip_host(Rest, State, Method);
parse_uri(Buffer, State, Method) ->
parse_uri_path(Buffer, State, Method, <<>>).

View file

@ -153,13 +153,13 @@ setusercontext()
if [ ${user} = ${LEOFS_USER} ] if [ ${user} = ${LEOFS_USER} ]
then then
return return
fi fi
if [ ${user} != root ] if [ ${user} != root ]
then then
echo "Must be run as ${LEOFS_USER} user or root (or set LEOFS_USER)" >&2 echo "Must be run as ${LEOFS_USER} user or root (or set LEOFS_USER)" >&2
exit 1 exit 1
fi fi
# Restart as LEOFS_USER # Restart as LEOFS_USER
@ -187,17 +187,17 @@ gen_config()
args=`PATH=${ERTS_PATH}:${PATH} \ args=`PATH=${ERTS_PATH}:${PATH} \
${LEOFS_BASEDIR}/bin/cuttlefish \ ${LEOFS_BASEDIR}/bin/cuttlefish \
-i ${LEOFS_BASEDIR}/etc/${LEOFS_SERVER}.schema \ -i ${LEOFS_BASEDIR}/etc/${LEOFS_SERVER}.schema \
-c ${LEOFS_ETCDIR}/${LEOFS_SERVER}.conf \ -c ${LEOFS_ETCDIR}/${LEOFS_SERVER}.conf \
-d ${cfg_dir}` -d ${cfg_dir}`
app_config=`echo ${args} | sed -nEe 's/^.*(app\.[0-9.]*\.config).*$/\1/p'` app_config=`echo ${args} | sed -nEe 's/^.*(app\.[0-9.]*\.config).*$/\1/p'`
vm_args=`echo ${args} | sed -nEe 's/^.*(vm\.[0-9.]*\.args).*$/\1/p'` vm_args=`echo ${args} | sed -nEe 's/^.*(vm\.[0-9.]*\.args).*$/\1/p'`
if [ -z "${app_config}" -o -z "${vm_args}" ] if [ -z "${app_config}" -o -z "${vm_args}" ]
then then
echo "Failed to parse ${LEOFS_SERVER}.conf" >&2 echo "Failed to parse ${LEOFS_SERVER}.conf" >&2
exit 1 exit 1
fi fi
# Sanity check the app.config file # Sanity check the app.config file
@ -248,10 +248,10 @@ make_env()
snmp_cfg=`sed -nEe 's/^-config *(.*)$/\1.config/p' ${LEOFS_DBDIR}/etc/vm.args` snmp_cfg=`sed -nEe 's/^-config *(.*)$/\1.config/p' ${LEOFS_DBDIR}/etc/vm.args`
sed -nEe 's:^.*dir, *"((%%LEOFS_DBDIR%%|%%LEOFS_LOGDIR%%)[^"]*)".*$:\1:p' \ sed -nEe 's:^.*dir, *"((%%LEOFS_DBDIR%%|%%LEOFS_LOGDIR%%)[^"]*)".*$:\1:p' \
${LEOFS_DBDIR}/etc/app.config ${snmp_cfg} | sort -u | ${LEOFS_DBDIR}/etc/app.config ${snmp_cfg} | sort -u |
while read dir while read dir
do do
mkdir -p "${dir}" mkdir -p "${dir}"
done done
} }
@ -268,15 +268,15 @@ nodetool()
name_arg=`egrep '^-s?name' ${vmargs_path}` name_arg=`egrep '^-s?name' ${vmargs_path}`
if [ -z "${name_arg}" ] if [ -z "${name_arg}" ]
then then
echo "vm.args needs either -name or -sname parameter" >&2 echo "vm.args needs either -name or -sname parameter" >&2
exit 1 exit 1
fi fi
cookie_arg=`grep '^-setcookie' ${vmargs_path}` cookie_arg=`grep '^-setcookie' ${vmargs_path}`
if [ -z "${cookie_arg}" ] if [ -z "${cookie_arg}" ]
then then
echo "vm.args needs a -setcookie parameter" 2>&2 echo "vm.args needs a -setcookie parameter" 2>&2
exit 1 exit 1
fi fi
${ERTS_PATH}/escript ${ERTS_PATH}/nodetool ${name_arg} ${cookie_arg} ${cmd} ${ERTS_PATH}/escript ${ERTS_PATH}/nodetool ${name_arg} ${cookie_arg} ${cmd}
@ -293,17 +293,17 @@ check_node()
if [ "${expected_state}" = DOWN ] if [ "${expected_state}" = DOWN ]
then then
if [ ${status} -eq 0 ] if [ ${status} -eq 0 ]
then then
echo "Node is already running" >&2 echo "Node is already running" >&2
exit 1 exit 1
fi fi
else else
if [ ${status} -ne 0 ] if [ ${status} -ne 0 ]
then then
echo "Node is not running" >&2 echo "Node is not running" >&2
exit 1 exit 1
fi fi
fi fi
} }
@ -318,15 +318,15 @@ remsh()
name_arg=`egrep '^-s?name' ${vmargs_path}` name_arg=`egrep '^-s?name' ${vmargs_path}`
if [ -z "${name_arg}" ] if [ -z "${name_arg}" ]
then then
echo "vm.args needs either -name or -sname parameter" >&2 echo "vm.args needs either -name or -sname parameter" >&2
exit 1 exit 1
fi fi
cookie_arg=`grep '^-setcookie' ${vmargs_path}` cookie_arg=`grep '^-setcookie' ${vmargs_path}`
if [ -z "${cookie_arg}" ] if [ -z "${cookie_arg}" ]
then then
echo "vm.args needs a -setcookie parameter" 2>&2 echo "vm.args needs a -setcookie parameter" 2>&2
exit 1 exit 1
fi fi
# Extract the name type and name from the name_arg for remsh # Extract the name type and name from the name_arg for remsh
@ -558,6 +558,8 @@ register_cmd restart
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
cmd_start() cmd_start()
{ {
local i res
case "$1" in case "$1" in
help_summary) help_summary)
echo "Launch the application" echo "Launch the application"
@ -577,7 +579,21 @@ cmd_start()
export HEART_COMMAND="${PROGPATH} ${LEOFS_SERVER} start" export HEART_COMMAND="${PROGPATH} ${LEOFS_SERVER} start"
${ERTS_PATH}/run_erl -daemon ${LEOFS_PIPE} ${LEOFS_LOGDIR} \ ${ERTS_PATH}/run_erl -daemon ${LEOFS_PIPE} ${LEOFS_LOGDIR} \
"exec ${PROGPATH} ${LEOFS_SERVER} console $@" 2>&1 "exec ${PROGPATH} ${LEOFS_SERVER} console $@" 2>&1
res=$?
if [ "${res}" -ne 0 ]
then
exit ${res}
fi
# Wait up to 1 minute for the node to start responding on ping.
for i in `jot 60`
do
nodetool ping >/dev/null 2>&1 || exit 0
sleep 1
done
exit 1
} }
register_cmd start register_cmd start
@ -610,19 +626,19 @@ cmd_stop()
if [ "${res}" -ne 0 ] if [ "${res}" -ne 0 ]
then then
if [ -z "${pid}" ] if [ -z "${pid}" ]
then then
echo "${LEOFS_SERVER} is not running" echo "${LEOFS_SERVER} is not running"
else else
echo "Failed to stop ${LEOFS_SERVER}" echo "Failed to stop ${LEOFS_SERVER}"
fi fi
exit ${res} exit ${res}
fi fi
# Wait up to 1 minute for the process to terminate. # Wait up to 1 minute for the process to terminate.
for i in `jot 60` for i in `jot 60`
do do
kill -0 ${pid} 2>/dev/null || exit 0 kill -0 ${pid} 2>/dev/null || exit 0
sleep 1 sleep 1
done done
echo "Failed to terminate the ${LEOFS_SERVER} process (pid ${pid})" echo "Failed to terminate the ${LEOFS_SERVER} process (pid ${pid})"