Merge pull request #7952 from zhongwencool/emqx-service-not-found
fix: emqx can't start with systemctl
This commit is contained in:
commit
850df81840
|
@ -16,12 +16,13 @@ TAR_PKG := $(EMQX_REL)/$(TAR_PKG_DIR)/emqx-$(PKG_VSN).tar.gz
|
||||||
SOURCE_PKG := emqx-$(RPM_VSN)-$(RPM_REL).$(shell uname -m)
|
SOURCE_PKG := emqx-$(RPM_VSN)-$(RPM_REL).$(shell uname -m)
|
||||||
TARGET_PKG := $(EMQX_NAME)-$(shell $(EMQX_REL)/pkg-vsn.sh $(EMQX_NAME) --long)
|
TARGET_PKG := $(EMQX_NAME)-$(shell $(EMQX_REL)/pkg-vsn.sh $(EMQX_NAME) --long)
|
||||||
|
|
||||||
SYSTEMD := $(shell if command -v systemctl >/dev/null 2>&1; then echo yes; fi)
|
|
||||||
# Not $(PWD) as it does not work for make -C
|
# Not $(PWD) as it does not work for make -C
|
||||||
CURDIR := $(shell pwd)
|
CURDIR := $(shell pwd)
|
||||||
|
|
||||||
POST_ADDITION := $(if $(SYSTEMD),%systemd_post %{_name}.service,echo post)
|
POST_ADDITION := %systemd_post %{_name}.service
|
||||||
PREUN_ADDITION := $(if $(SYSTEMD),%systemd_preun %{_name}.service,echo preun)
|
PREUN_ADDITION := %systemd_preun %{_name}.service
|
||||||
|
SERVICE_SRC := $(CURDIR)/emqx.service
|
||||||
|
SERVICE_DST := %{_unitdir}/emqx.service
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: | $(BUILT)
|
all: | $(BUILT)
|
||||||
|
@ -36,6 +37,8 @@ all: | $(BUILT)
|
||||||
--define "_post_addition $(POST_ADDITION)" \
|
--define "_post_addition $(POST_ADDITION)" \
|
||||||
--define "_preun_addition $(PREUN_ADDITION)" \
|
--define "_preun_addition $(PREUN_ADDITION)" \
|
||||||
--define "_sharedstatedir /var/lib" \
|
--define "_sharedstatedir /var/lib" \
|
||||||
|
--define "_service_src $(SERVICE_SRC)" \
|
||||||
|
--define "_service_dst $(SERVICE_DST)" \
|
||||||
emqx.spec
|
emqx.spec
|
||||||
mkdir -p $(EMQX_REL)/_packages/$(EMQX_NAME)
|
mkdir -p $(EMQX_REL)/_packages/$(EMQX_NAME)
|
||||||
cp $(TOPDIR)/RPMS/$(shell uname -m)/$(SOURCE_PKG).rpm $(EMQX_REL)/_packages/$(EMQX_NAME)/$(TARGET_PKG).rpm
|
cp $(TOPDIR)/RPMS/$(shell uname -m)/$(SOURCE_PKG).rpm $(EMQX_REL)/_packages/$(EMQX_NAME)/$(TARGET_PKG).rpm
|
||||||
|
|
|
@ -47,6 +47,7 @@ cp -R %{_reldir}/releases %{buildroot}%{_lib_home}/
|
||||||
cp -R %{_reldir}/bin %{buildroot}%{_lib_home}/
|
cp -R %{_reldir}/bin %{buildroot}%{_lib_home}/
|
||||||
cp -R %{_reldir}/etc/* %{buildroot}%{_conf_dir}/
|
cp -R %{_reldir}/etc/* %{buildroot}%{_conf_dir}/
|
||||||
cp -R %{_reldir}/data/* %{buildroot}%{_var_home}/
|
cp -R %{_reldir}/data/* %{buildroot}%{_var_home}/
|
||||||
|
install -m644 %{_service_src} %{buildroot}%{_service_dst}
|
||||||
|
|
||||||
%pre
|
%pre
|
||||||
if [ $1 = 1 ]; then
|
if [ $1 = 1 ]; then
|
||||||
|
@ -84,6 +85,7 @@ exit 0
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%defattr(-,root,root)
|
%defattr(-,root,root)
|
||||||
|
%{_service_dst}
|
||||||
%attr(-,%{_user},%{_group}) %{_lib_home}/*
|
%attr(-,%{_user},%{_group}) %{_lib_home}/*
|
||||||
%attr(-,%{_user},%{_group}) %dir %{_var_home}
|
%attr(-,%{_user},%{_group}) %dir %{_var_home}
|
||||||
%attr(-,%{_user},%{_group}) %config(noreplace) %{_var_home}/*
|
%attr(-,%{_user},%{_group}) %config(noreplace) %{_var_home}/*
|
||||||
|
|
|
@ -150,7 +150,11 @@ emqx_test(){
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
"rpm")
|
"rpm")
|
||||||
yum install -y "${PACKAGE_PATH}/${packagename}"
|
YUM_RES=$(yum install -y "${PACKAGE_PATH}/${packagename}"| tee /dev/null)
|
||||||
|
if [[ $YUM_RES =~ "Failed" ]]; then
|
||||||
|
echo "yum install failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
if ! rpm -q "${EMQX_NAME}" | grep -q "${EMQX_NAME}"; then
|
if ! rpm -q "${EMQX_NAME}" | grep -q "${EMQX_NAME}"; then
|
||||||
echo "package install error"
|
echo "package install error"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -189,7 +193,6 @@ EOF
|
||||||
echo "Error: cannot locate emqx_vars"
|
echo "Error: cannot locate emqx_vars"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! emqx 'start'; then
|
if ! emqx 'start'; then
|
||||||
cat /var/log/emqx/erlang.log.1 || true
|
cat /var/log/emqx/erlang.log.1 || true
|
||||||
cat /var/log/emqx/emqx.log.1 || true
|
cat /var/log/emqx/emqx.log.1 || true
|
||||||
|
|
Loading…
Reference in New Issue