Merge pull request #5204 from proller/fix25

CLICKHOUSE-4511 Fix forcerestart with systemd
This commit is contained in:
alexey-milovidov 2019-05-09 12:19:47 +03:00 committed by GitHub
commit 31655abc09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 9 deletions

View File

@ -56,7 +56,7 @@ if [ "$DATA_DIR_PATTERN" != "$DATA_DIR" ]; then
cat $CLICKHOUSE_CONFIG | sed -e s!$DATA_DIR_PATTERN!$DATA_DIR! > $DATA_DIR/etc/server-config.xml
export CLICKHOUSE_CONFIG=$DATA_DIR/etc/server-config.xml
cp $CLICKHOUSE_CONFIG_USERS $DATA_DIR/etc
cp -r -L $CLICKHOUSE_CONFIG_USERS_D $DATA_DIR/etc
cp -R -L $CLICKHOUSE_CONFIG_USERS_D $DATA_DIR/etc
fi
CLICKHOUSE_EXTRACT_CONFIG=${CLICKHOUSE_EXTRACT_CONFIG:="${CLICKHOUSE_EXTRACT} --config=$CLICKHOUSE_CONFIG"}

View File

@ -235,10 +235,20 @@ forcestop()
}
service_or_func()
{
if [ -x "/bin/systemctl" ] && [ -f /etc/systemd/system/clickhouse-server.service ] && [ -d /run/systemd/system ]; then
service $PROGRAM $1
else
$1
fi
}
forcerestart()
{
forcestop
start
# Should not use 'start' function if systemd active
service_or_func start
}
use_cron()
@ -291,7 +301,9 @@ main()
restart && enable_cron
;;
forcestop)
disable_cron && forcestop
# disable_cron returns false if cron disabled (with systemd) - not checking return status
disable_cron
forcestop
;;
forcerestart)
forcerestart && enable_cron
@ -300,16 +312,16 @@ main()
restart
;;
condstart)
is_running || start
is_running || service_or_func start
;;
condstop)
is_running && stop
is_running && service_or_func stop
;;
condrestart)
is_running && restart
is_running && service_or_func restart
;;
condreload)
is_running && restart
is_running && service_or_func restart
;;
initdb)
initdb

View File

@ -7,7 +7,8 @@ User=clickhouse
Group=clickhouse
Restart=always
RestartSec=30
ExecStart=/usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml
RuntimeDirectory=clickhouse-server
ExecStart=/usr/bin/clickhouse-server --config=/etc/clickhouse-server/config.xml --pid-file=/run/clickhouse-server/clickhouse-server.pid
LimitCORE=infinity
LimitNOFILE=500000
CapabilityBoundingSet=CAP_NET_ADMIN CAP_IPC_LOCK

View File

@ -1083,7 +1083,7 @@ void BaseDaemon::initialize(Application & self)
}
/// Create pid file.
if (is_daemon && config().has("pid"))
if (config().has("pid"))
pid.seed(config().getString("pid"));
/// Change path for logging.