Skip to content

Commit 56fc743

Browse files
author
Andrei Zavada
committed
upgrade rebar3 to 3.17 plus git revlist fix
See TI-Tokyo/rebar3@48344c200353c It comes with a new relx which allows for many simplifications in the launcher script: * The riak script it generates has rpc facility built in. * No need to supply dummy sys.config and vm.args. We do, however, need to write and delete the pid file ourselves.
1 parent 4ec03f3 commit 56fc743

File tree

11 files changed

+260
-259
lines changed

11 files changed

+260
-259
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ compile:
3030

3131
deps:
3232
$(if $(HEAD_REVISION),$(warning "Warning: you have checked out a tag ($(HEAD_REVISION)) and should use the compile target"))
33-
$(REBAR) upgrade
33+
$(REBAR) upgrade --all
3434

3535
clean: testclean
3636
$(REBAR) clean

rebar.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
]}
4747
]}.
4848

49-
{relx, [{release, {riak, "3.0.9"},
49+
{relx, [{release, {riak, "3.0.9.1"},
5050
[kernel,
5151
stdlib,
5252
lager,

rebar.lock

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{"1.1.0",
1+
{"1.2.0",
22
[{<<"basho_stats">>,
33
{git,"https://github.com/basho/basho_stats.git",
44
{ref,"c5b7ecb92af7b050bc62d08c6fbf1aafd6bdeff0"}},
@@ -180,5 +180,12 @@
180180
{<<"goldrush">>, <<"F06E5D5F1277DA5C413E84D5A2924174182FB108DABB39D5EC548B27424CD106">>},
181181
{<<"hut">>, <<"08D46679523043424870723923971889E8A34D63B2F946A35B46CF921D1236E7">>},
182182
{<<"parse_trans">>, <<"09765507A3C7590A784615CFD421D101AEC25098D50B89D7AA1D66646BC571C1">>},
183-
{<<"setup">>, <<"1203F4CDA11306C2E34434244576DED0A7BBFB0908D9A572356C809BD0CDF085">>}]}
183+
{<<"setup">>, <<"1203F4CDA11306C2E34434244576DED0A7BBFB0908D9A572356C809BD0CDF085">>}]},
184+
{pkg_hash_ext,[
185+
{<<"bear">>, <<"534217DCE6A719D59E54FB0EB7A367900DBFC5F85757E8C1F94269DF383F6D9B">>},
186+
{<<"folsom">>, <<"F7B644FC002A75AF00B8BFBD3CC5C2BD955E09A118D2982D9A6C04E5646FF367">>},
187+
{<<"goldrush">>, <<"99CB4128CFFCB3227581E5D4D803D5413FA643F4EB96523F77D9E6937D994CEB">>},
188+
{<<"hut">>, <<"953FC447514BAF9CC79FA147D66469243C94DFA1593779614E070C692D0BF0F3">>},
189+
{<<"parse_trans">>, <<"17EF63ABDE837AD30680EA7F857DD9E7CED9476CDD7B0394432AF4BFC241B960">>},
190+
{<<"setup">>, <<"7D6AAF5281D0B0C40980E128F9DC410DACD03799A8577201D4C8B43E7F97509A">>}]}
184191
].

rebar3

103 KB
Binary file not shown.

rel/files/riak

Lines changed: 67 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,75 @@
11
#!/bin/bash
22

3-
RUNNER_GEN_DIR="${RUNNER_GEN_DIR:-{{ platform_gen_dir }}}"
4-
RELEASE_ROOT_DIR="${RELEASE_ROOT_DIR:-{{ runner_base_dir }}}"
3+
RUNNER_GEN_DIR={{platform_gen_dir}}
4+
RELX_RIAK={{platform_bin_dir}}/riak
55
PID_DIR={{pid_dir}}
6-
COMMAND={{platform_bin_dir}}/riak
7-
DEBUG_COMMAND={{platform_bin_dir}}/riak-debug
8-
RUNNER_LOG_DIR={{platform_log_dir}}
9-
RELX_CONFIG_PATH=${RUNNER_GEN_DIR}/sys.config
10-
VMARGS_PATH=${RUNNER_GEN_DIR}/vm.args
6+
PIPE_DIR={{pipe_dir}}/ # terminating / (relx treats it as a prefix)
117

8+
mkdir -p $PID_DIR $PIPE_DIR
9+
chown riak:riak $PID_DIR $PIPE_DIR
1210

13-
# On first running the sys.config and vm.args will not be a link
14-
# as cfconfig has not yet been run as a pre_start hook. If there's no
15-
# link use the default for now
16-
if [ ! -L $RELX_CONFIG_PATH ]; then
17-
cp $RELEASE_ROOT_DIR/releases/{{release_version}}/sys.config $RELX_CONFIG_PATH
18-
fi
19-
if [ ! -L $VMARGS_PATH ]; then
20-
cp $RELEASE_ROOT_DIR/releases/{{release_version}}/vm.args $VMARGS_PATH
21-
fi
11+
function write_pid_file { # relx doesn't seem to write the pid file, does it?
12+
local c=3
13+
sleep 1
14+
while [[ $c -ne 0 ]]; do
15+
if [ "`maybe_su ${RELX_RIAK} ping`" = "pong" ]; then
16+
maybe_su ${RELX_RIAK} pid >$PID_DIR/riak.pid
17+
# systemd wants it to be owned by root, so:
18+
chown root:root $PID_DIR/riak.pid 2&>1 >/dev/null \
19+
|| true # if we are run as non-root, just never mind
20+
break
21+
fi
22+
sleep 2
23+
c=$(($c - 1))
24+
done
25+
}
2226

23-
# When running as a service, running as riak not as root, and systemd has created PID folder
24-
if [[ $EUID -ne 0 ]]; then
25-
case "$1" in
26-
start|console|foreground)
27-
RELX_CONFIG_PATH=${RELX_CONFIG_PATH} VMARGS_PATH=${VMARGS_PATH} RUNNER_LOG_DIR=${RUNNER_LOG_DIR} PIPE_DIR=${PIPE_DIR} ${COMMAND} ${*} -pa {{platform_lib_dir}}/patches
28-
;;
29-
*)
30-
RELX_CONFIG_PATH=${RELX_CONFIG_PATH} VMARGS_PATH=${VMARGS_PATH} RUNNER_LOG_DIR=${RUNNER_LOG_DIR} PIPE_DIR=${PIPE_DIR} ${COMMAND} ${*}
31-
;;
32-
esac
33-
else
34-
# In this case we're running sudo riak - so have root access, but cannot rely
35-
# systemd having created the PID dir, and need to sudo to the riak user
36-
if [ ! -d $PID_DIR ]; then
37-
mkdir $PID_DIR
38-
chown riak:riak $PID_DIR
39-
fi
40-
case "$1" in
41-
start|console|foreground)
42-
su - riak -c "NODETOOL_NODE_PREFIX=${NODETOOL_NODE_PREFIX} RELX_CONFIG_PATH=${RELX_CONFIG_PATH} VMARGS_PATH=${VMARGS_PATH} RUNNER_LOG_DIR=${RUNNER_LOG_DIR} PIPE_DIR=${PIPE_DIR} ${COMMAND} ${*} -pa {{platform_lib_dir}}/patches"
43-
;;
44-
debug)
45-
# Drop the "debug" from the args as we're going to directly call riak-debug now
46-
shift
47-
# Debug may fail if run via relx script due to use of relative start location, and also need for root access
48-
NODETOOL_NODE_PREFIX=${NODETOOL_NODE_PREFIX} RELX_CONFIG_PATH=${RELX_CONFIG_PATH} VMARGS_PATH=${VMARGS_PATH} RUNNER_LOG_DIR=${RUNNER_LOG_DIR} PIPE_DIR=${PIPE_DIR} ${DEBUG_COMMAND} ${*}
49-
;;
50-
*)
51-
ESCAPED_ARGS=`echo "$@" | sed -e 's/\([\\\(\\\){}"\x27]\)/\\\\\1/g'`
52-
su - riak -c "NODETOOL_NODE_PREFIX=${NODETOOL_NODE_PREFIX} RELX_CONFIG_PATH=${RELX_CONFIG_PATH} VMARGS_PATH=${VMARGS_PATH} RUNNER_LOG_DIR=${RUNNER_LOG_DIR} PIPE_DIR=${PIPE_DIR} ${COMMAND} ${ESCAPED_ARGS}"
53-
;;
54-
esac
55-
fi
27+
function delete_pid_file {
28+
rm -f $PID_DIR/riak.pid
29+
}
5630

31+
function maybe_su {
32+
if [[ $EUID -ne 0 ]]; then
33+
NODETOOL_NODE_PREFIX=${NODETOOL_NODE_PREFIX} PIPE_DIR=${PIPE_DIR} $*
34+
else
35+
# freebsd su is fairly limited, so:
36+
f=$RUNNER_GEN_DIR/su_piggy
37+
cat >$f <<EOF
38+
#!/bin/sh
39+
NODETOOL_NODE_PREFIX=${NODETOOL_NODE_PREFIX} PIPE_DIR=$PIPE_DIR $*
40+
EOF
41+
chmod +x $f
42+
su - riak $f
43+
fi
44+
}
5745

46+
case "$1" in
47+
start)
48+
maybe_su $RELX_RIAK $* -pa {{runner_patch_dir}} \
49+
&& write_pid_file
50+
test -r $PID_DIR/riak.pid && exit 0
51+
;;
52+
console|foreground)
53+
maybe_su $RELX_RIAK $* -pa {{runner_patch_dir}}
54+
;;
55+
stop)
56+
maybe_su $RELX_RIAK $* \
57+
&& delete_pid_file
58+
;;
59+
admin)
60+
shift
61+
maybe_su `which riak-admin` $*
62+
;;
63+
repl)
64+
shift
65+
maybe_su `which riak-repl` $*
66+
;;
67+
debug)
68+
shift
69+
maybe_su `which riak-debug` $*
70+
;;
71+
*)
72+
ESCAPED_ARGS=`echo "$@" | sed -e 's/\([\\\(\\\){}"\x27]\)/\\\\\1/g'`
73+
maybe_su $RELX_RIAK $ESCAPED_ARGS
74+
;;
75+
esac

0 commit comments

Comments
 (0)