Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BIGTOP-4197. Provide systemd service unit files(RPM): ZooKeeper #1295

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions bigtop-packages/src/common/zookeeper/zookeeper-server.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

[Unit]
Documentation=https://zookeeper.apache.org/
Description=ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services.
Before=multi-user.target
Before=graphical.target
After=network-online.target
After=nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=no
PIDFile=/var/run/zookeeper/zookeeper_server.pid
SuccessExitStatus=5 6
ExecStart=/etc/rc.d/init.d/zookeeper-server start
ExecStop=/etc/rc.d/init.d/zookeeper-server stop
14 changes: 12 additions & 2 deletions bigtop-packages/src/rpm/zookeeper/SPECS/zookeeper.spec
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ Source6: zoo.cfg
Source7: zookeeper.default
Source8: init.d.tmpl
Source9: zookeeper-rest.svc
Source10: zookeeper-server.service
#BIGTOP_PATCH_FILES
BuildRequires: autoconf, automake, cppunit-devel
BuildRequires: autoconf, automake, cppunit-devel, systemd
Requires(pre): coreutils, /usr/sbin/groupadd, /usr/sbin/useradd
Requires(post): %{alternatives_dep}
Requires(preun): %{alternatives_dep}
Expand Down Expand Up @@ -193,6 +194,9 @@ chmod 755 $init_file
init_file=$RPM_BUILD_ROOT/%{initd_dir}/zookeeper-rest
bash $RPM_SOURCE_DIR/init.d.tmpl $RPM_SOURCE_DIR/zookeeper-rest.svc rpm $init_file

# Install ZooKeeper Server systemd service file
%__install -D -m 0644 %{SOURCE10} $RPM_BUILD_ROOT/%{_unitdir}/zookeeper-server.service

%pre
getent group zookeeper >/dev/null || groupadd -r zookeeper
getent passwd zookeeper > /dev/null || useradd -c "ZooKeeper" -s /sbin/nologin -g zookeeper -r -d %{var_lib_zookeeper} zookeeper 2> /dev/null || :
Expand All @@ -205,24 +209,29 @@ getent passwd zookeeper > /dev/null || useradd -c "ZooKeeper" -s /sbin/nologin -
%{alternatives_cmd} --install %{np_etc_zookeeper}/conf %{zookeeper_name}-conf %{etc_zookeeper_conf_dist} 30
%__install -d -o zookeeper -g zookeeper -m 0755 %{var_lib_zookeeper}


%preun
if [ "$1" = 0 ]; then
%{alternatives_cmd} --remove %{zookeeper_name}-conf %{etc_zookeeper_conf_dist} || :
fi


%post server
chkconfig --add %{svc_zookeeper}
chkconfig --add %{svc_zookeeper}
%systemd_post zookeeper-server.service

%preun server
if [ $1 = 0 ] ; then
service %{svc_zookeeper} stop > /dev/null 2>&1
chkconfig --del %{svc_zookeeper}
fi
%systemd_preun zookeeper-server.service

%postun server
if [ $1 -ge 1 ]; then
service %{svc_zookeeper} condrestart > /dev/null 2>&1
fi
%systemd_postun zookeeper-server.service

%post rest
chkconfig --add %{svc_zookeeper_rest}
Expand Down Expand Up @@ -256,6 +265,7 @@ fi

%files server
%attr(0755,root,root) %{initd_dir}/%{svc_zookeeper}
%attr(0644,root,root) %{_unitdir}/zookeeper-server.service

%files rest
%attr(0755,root,root) %{initd_dir}/%{svc_zookeeper_rest}
Expand Down