mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
Simplify init script
This commit is contained in:
parent
c53854df19
commit
f7e93531f8
69
debian/clickhouse-server.init
vendored
69
debian/clickhouse-server.init
vendored
@ -160,82 +160,19 @@ initdb()
|
|||||||
|
|
||||||
start()
|
start()
|
||||||
{
|
{
|
||||||
[ -x $CLICKHOUSE_BINDIR/$PROGRAM ] || exit 0
|
${CLICKHOUSE_GENERIC_PROGRAM} start --user "${CLICKHOUSE_USER}" --pid-path "${CLICKHOUSE_PIDDIR}" --config-path "${CLICKHOUSE_CONFDIR}" --binary-path "${CLICKHOUSE_BINDIR}/${PROGRAM}"
|
||||||
local EXIT_STATUS
|
|
||||||
EXIT_STATUS=0
|
|
||||||
|
|
||||||
echo -n "Start $PROGRAM service: "
|
|
||||||
|
|
||||||
if is_running; then
|
|
||||||
echo -n "already running "
|
|
||||||
EXIT_STATUS=1
|
|
||||||
else
|
|
||||||
ulimit -n 262144
|
|
||||||
mkdir -p $CLICKHOUSE_PIDDIR
|
|
||||||
chown -R $CLICKHOUSE_USER:$CLICKHOUSE_GROUP $CLICKHOUSE_PIDDIR
|
|
||||||
initdb
|
|
||||||
if ! is_running; then
|
|
||||||
# Lock should not be held while running child process, so we release the lock. Note: obviously, there is race condition.
|
|
||||||
# But clickhouse-server has protection from simultaneous runs with same data directory.
|
|
||||||
su -s $SHELL ${CLICKHOUSE_USER} -c "$FLOCK -u 9; $CLICKHOUSE_PROGRAM_ENV exec -a \"$PROGRAM\" \"$CLICKHOUSE_BINDIR/$PROGRAM\" --daemon --pid-file=\"$CLICKHOUSE_PIDFILE\" --config-file=\"$CLICKHOUSE_CONFIG\""
|
|
||||||
EXIT_STATUS=$?
|
|
||||||
if [ $EXIT_STATUS -ne 0 ]; then
|
|
||||||
return $EXIT_STATUS
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $EXIT_STATUS -eq 0 ]; then
|
|
||||||
attempts=0
|
|
||||||
while ! is_running && [ $attempts -le ${CLICKHOUSE_START_TIMEOUT:=10} ]; do
|
|
||||||
attempts=$(($attempts + 1))
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
if is_running; then
|
|
||||||
echo "DONE"
|
|
||||||
else
|
|
||||||
echo "UNKNOWN"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "FAILED"
|
|
||||||
fi
|
|
||||||
|
|
||||||
return $EXIT_STATUS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
stop()
|
stop()
|
||||||
{
|
{
|
||||||
#local EXIT_STATUS
|
${CLICKHOUSE_GENERIC_PROGRAM} stop --pid-path "${CLICKHOUSE_PIDDIR}"
|
||||||
EXIT_STATUS=0
|
|
||||||
|
|
||||||
if [ -f $CLICKHOUSE_PIDFILE ]; then
|
|
||||||
|
|
||||||
echo -n "Stop $PROGRAM service: "
|
|
||||||
|
|
||||||
kill -TERM $(cat "$CLICKHOUSE_PIDFILE")
|
|
||||||
|
|
||||||
if ! wait_for_done ${CLICKHOUSE_STOP_TIMEOUT}; then
|
|
||||||
EXIT_STATUS=2
|
|
||||||
echo "TIMEOUT"
|
|
||||||
else
|
|
||||||
echo "DONE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
return $EXIT_STATUS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
restart()
|
restart()
|
||||||
{
|
{
|
||||||
check_config
|
${CLICKHOUSE_GENERIC_PROGRAM} restart --user "${CLICKHOUSE_USER}" --pid-path "${CLICKHOUSE_PIDDIR}" --config-path "${CLICKHOUSE_CONFDIR}" --binary-path "${CLICKHOUSE_BINDIR}/${PROGRAM}"
|
||||||
if stop; then
|
|
||||||
if start; then
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user