注册为 systemctl 服务

最后更新于:2022-04-02 03:54:56

[TOC] ## 实例 vim SOURCES/units/upantbiz.service ``` [Unit] Description=upantbiz server [Service] Type=forking ExecStart=/opt/im_user/im_server/im_server/antGo/UpAntbizServer ExecStop=pkill UpAntBizServer PrivateTmp=true Restart=always RestartSec=5 Environment=LD_LIBRARY_PATH=/opt/im_user/im_server/im_server/im_common/:/opt/im_user/im_server/im_webserver/common [Install] WantedBy=multi-user.target ``` vim SPECS/antimserver.spec ``` %post echo "注册服务" systemctl daemon-reload echo "开机启动" systemctl enable im_server.service echo "启动服务" systemctl start im_server ... %preun # 停服务 systemctl stop im_server #卸载服务 systemctl disable im_server ... %install cp -rf ${SOURCES}/units/nginx.service ${ROOT}/usr/lib/systemd/system ``` [查看 github 的实例 idcpj/rpm_deb_build](https://github.com/idcpj/rpm_deb_build)
';