diff options
| author | lijia <[email protected]> | 2020-01-09 12:29:10 +0800 |
|---|---|---|
| committer | lijia <[email protected]> | 2020-01-09 12:29:10 +0800 |
| commit | 6f793d36e120114bebc50d6aaeb3c235380bcd17 (patch) | |
| tree | 0bad0b73fef245cbfc9511710f1b5d91b376e7a7 | |
| parent | d03e1acc434f7d0ff8ff910b606229107d8742b8 (diff) | |
rpm安装时自动注册系统服务.
| -rw-r--r-- | CMakeLists.txt | 2 | ||||
| -rw-r--r-- | bin/etc/sapp.toml | 2 | ||||
| -rw-r--r-- | cmake/Package.cmake | 27 | ||||
| -rw-r--r-- | cmake/PostInstall.in | 1 | ||||
| -rw-r--r-- | service/CMakeLists.txt | 12 | ||||
| -rw-r--r-- | service/fake_sapp | bin | 8496 -> 0 bytes | |||
| -rw-r--r-- | service/sapp-env-default.service.in | 14 | ||||
| -rw-r--r-- | service/sapp-env-marsio.service.in | 14 | ||||
| -rw-r--r-- | service/sapp_default.service.in | 7 | ||||
| -rw-r--r-- | service/sapp_marsio.service.in | 8 | ||||
| -rw-r--r-- | service/setup.sh | 30 | ||||
| -rw-r--r-- | version.txt | 14 |
12 files changed, 31 insertions, 100 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ae8ef1..02fac99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,7 +169,7 @@ add_subdirectory(./src/inner_plug) add_subdirectory(./src/timer) add_subdirectory(./src/entry) add_subdirectory(./test) -#add_subdirectory(./service) +add_subdirectory(./service) add_subdirectory(./tools) #by default, not include sapp_module_test dir diff --git a/bin/etc/sapp.toml b/bin/etc/sapp.toml index e7454d7..fece67f 100644 --- a/bin/etc/sapp.toml +++ b/bin/etc/sapp.toml @@ -9,7 +9,7 @@ instance_name = "sapp_v4.0" [CPU] -worker_threads=2 +worker_threads=1 ### note, bind_mask, if you do not want to bind thread to special CPU core, keep it empty as [] bind_mask=[] diff --git a/cmake/Package.cmake b/cmake/Package.cmake index 1593dd8..3a41f03 100644 --- a/cmake/Package.cmake +++ b/cmake/Package.cmake @@ -25,30 +25,23 @@ set(CPACK_RPM_DEBUGINFO_PACKAGE off) set(CPACK_BUILD_SOURCE_DIRS "${CMAKE_SOURCE_DIR}") -# Must uninstall the debug package before install release package +#Must uninstall the debug package before install release package if(CMAKE_BUILD_TYPE STREQUAL "Debug") set(CPACK_RPM_PACKAGE_CONFLICTS "${project_name}-debug") else() set(CPACK_RPM_PACKAGE_CONFLICTS ${project_name}) - # set(CPACK_STRIP_FILES TRUE) + set(CPACK_STRIP_FILES TRUE) endif() -#set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/cmake/preinstall.in) +set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/cmake/PostInstall.in) -if(CAPTURE_MODE MATCHES "MARSIO") - set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/cmake/postinstall_mrzcpd.in) -else() - set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/cmake/postinstall_pcap.in) -endif() - -# setup %config(noreplace) +#setup %config(noreplace) set(CPACK_RPM_USER_FILELIST "%config(noreplace) ${CMAKE_INSTALL_PREFIX}/etc/gdev.conf" - "%config(noreplace) ${CMAKE_INSTALL_PREFIX}/etc/sapp.toml" - "%config(noreplace) ${CMAKE_INSTALL_PREFIX}/etc/send_raw_pkt.conf" - "%config(noreplace) ${CMAKE_INSTALL_PREFIX}/etc/project_list.conf" - "%config(noreplace) ${CMAKE_INSTALL_PREFIX}/etc/plugin.conf" - "%config(noreplace) ${CMAKE_INSTALL_PREFIX}/etc/entrylist.conf" - "%config(noreplace) ${CMAKE_INSTALL_PREFIX}/plug/conflist.inf") - + "%config(noreplace) ${CMAKE_INSTALL_PREFIX}/etc/sapp.toml" + "%config(noreplace) ${CMAKE_INSTALL_PREFIX}/etc/send_raw_pkt.conf" + "%config(noreplace) ${CMAKE_INSTALL_PREFIX}/etc/project_list.conf" + "%config(noreplace) ${CMAKE_INSTALL_PREFIX}/etc/plugin.conf" + "%config(noreplace) ${CMAKE_INSTALL_PREFIX}/etc/entrylist.conf" + "%config(noreplace) ${CMAKE_INSTALL_PREFIX}/plug/conflist.inf") include(CPack) diff --git a/cmake/PostInstall.in b/cmake/PostInstall.in new file mode 100644 index 0000000..21c426b --- /dev/null +++ b/cmake/PostInstall.in @@ -0,0 +1 @@ +%systemd_post sapp.service diff --git a/service/CMakeLists.txt b/service/CMakeLists.txt index d5563dc..4e30779 100644 --- a/service/CMakeLists.txt +++ b/service/CMakeLists.txt @@ -1,14 +1,10 @@ if(CAPTURE_MODE MATCHES "MARSIO") - #configure_file(sapp_marsio.service.in sapp.service) - install(FILES ${PROJECT_SOURCE_DIR}/service/sapp-env-marsio.service.in DESTINATION /usr/lib/systemd/system/ RENAME sapp-env.service) - install(FILES ${PROJECT_SOURCE_DIR}/service/sapp_marsio.service.in DESTINATION /usr/lib/systemd/system/ RENAME sapp.service) + configure_file(sapp_marsio.service.in sapp.service) else() - #configure_file(sapp_default.service.in sapp.service) - install(FILES ${PROJECT_SOURCE_DIR}/service/sapp-env-default.service.in DESTINATION /usr/lib/systemd/system/ RENAME sapp-env.service) - install(FILES ${PROJECT_SOURCE_DIR}/service/sapp_default.service.in DESTINATION /usr/lib/systemd/system/ RENAME sapp.service) + configure_file(sapp_default.service.in sapp.service) endif() -install(PROGRAMS ${PROJECT_SOURCE_DIR}/service/setup.sh DESTINATION /opt/sapp/env) -install(PROGRAMS ${PROJECT_SOURCE_DIR}/service/fake_sapp DESTINATION /opt/sapp/bin) +install(FILES ${CMAKE_BINARY_DIR}/service/sapp.service DESTINATION /usr/lib/systemd/system COMPONENT Program) + diff --git a/service/fake_sapp b/service/fake_sapp Binary files differdeleted file mode 100644 index 0871d41..0000000 --- a/service/fake_sapp +++ /dev/null diff --git a/service/sapp-env-default.service.in b/service/sapp-env-default.service.in deleted file mode 100644 index 9c7d986..0000000 --- a/service/sapp-env-default.service.in +++ /dev/null @@ -1,14 +0,0 @@ -[Unit] -Description=set sapp environment -Requires=network.target -After=network.target -Before=sapp.service - -[Service] -ExecStart=/opt/sapp/env/setup.sh -Type=oneshot -RemainAfterExit=yes - -[Install] -WantedBy=multi-user.target -RequiredBy=sapp.service diff --git a/service/sapp-env-marsio.service.in b/service/sapp-env-marsio.service.in deleted file mode 100644 index d04cb67..0000000 --- a/service/sapp-env-marsio.service.in +++ /dev/null @@ -1,14 +0,0 @@ -[Unit] -Description=set sapp environment -Requires=mrzcpd.service -After=mrzcpd.service -Before=sapp.service - -[Service] -ExecStart=/opt/sapp/env/setup.sh -Type=oneshot -RemainAfterExit=yes - -[Install] -WantedBy=multi-user.target -RequiredBy=sapp.service diff --git a/service/sapp_default.service.in b/service/sapp_default.service.in index 47e0dfa..44ec7b8 100644 --- a/service/sapp_default.service.in +++ b/service/sapp_default.service.in @@ -1,11 +1,10 @@ [Unit] Description=sapp service -Requires=sapp-env.service -After=sapp-env.service +After=network.target [Service] -WorkingDirectory=/opt/sapp/bin/ -ExecStart=/opt/sapp/bin/fake_sapp +WorkingDirectory=${CMAKE_INSTALL_PREFIX} +ExecStart=${CMAKE_INSTALL_PREFIX}/sapp Restart=always RestartSec=5s diff --git a/service/sapp_marsio.service.in b/service/sapp_marsio.service.in index 47e0dfa..2774069 100644 --- a/service/sapp_marsio.service.in +++ b/service/sapp_marsio.service.in @@ -1,11 +1,11 @@ [Unit] Description=sapp service -Requires=sapp-env.service -After=sapp-env.service +Requires=mrzcpd.service +After=mrzcpd.service [Service] -WorkingDirectory=/opt/sapp/bin/ -ExecStart=/opt/sapp/bin/fake_sapp +WorkingDirectory=${CMAKE_INSTALL_PREFIX} +ExecStart=${CMAKE_INSTALL_PREFIX}/sapp Restart=always RestartSec=5s diff --git a/service/setup.sh b/service/setup.sh deleted file mode 100644 index e840df1..0000000 --- a/service/setup.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh - -systemctl enable sapp-env - -systemctl daemon-reload - -#sapp_install_dir=`rpm -qa --queryformat '%{name}-%{version} %{instprefixes}\n' sapp` -sapp_install_dir=`rpm -qa --queryformat '%{instprefixes}\n' sapp` - -echo "[Unit]" > /opt/sapp/env/sapp.service.tmp -echo "Description=sapp service" >> /opt/sapp/env/sapp.service.tmp -echo "Wants=network-online.target" >> /opt/sapp/env/sapp.service.tmp -echo "Requires=sapp-env.service" >> /opt/sapp/env/sapp.service.tmp -echo "After=sapp-env.service" >> /opt/sapp/env/sapp.service.tmp -echo "[Service]" >> /opt/sapp/env/sapp.service.tmp -echo "WorkingDirectory=$sapp_install_dir" >> /opt/sapp/env/sapp.service.tmp -echo "ExecStart=$sapp_install_dir/sapp" >> /opt/sapp/env/sapp.service.tmp -echo "Restart=always" >> /opt/sapp/env/sapp.service.tmp -echo "RestartSec=5s" >> /opt/sapp/env/sapp.service.tmp -echo "[Install]" >> /opt/sapp/env/sapp.service.tmp -echo "WantedBy=multi-user.target" >> /opt/sapp/env/sapp.service.tmp - -cp -f /opt/sapp/env/sapp.service.tmp /usr/lib/systemd/system/sapp.service - -#systemctl enable sapp -systemctl daemon-reload - - - - diff --git a/version.txt b/version.txt index 13bb84d..991d1cb 100644 --- a/version.txt +++ b/version.txt @@ -3,16 +3,16 @@ VCS_TYPE="git" VCS_BASENAME="v4.0" VCS_UUID="efa070923d8398b49f41acda82b839d11eb75230" -VCS_NUM="147" -VCS_DATE="2019-12-31T11:38:03+0800" -VCS_BRANCH="feature_inbound_outbound" -VCS_TAG="v4.0.7" -VCS_TICK="3" +VCS_NUM="151" +VCS_DATE="2020-01-07T10:33:50+0800" +VCS_BRANCH="sapp_v4.0_develop" +VCS_TAG="v4.0.8" +VCS_TICK="5" VCS_EXTRA="" VCS_ACTION_STAMP="" -VCS_FULL_HASH="06731c3bb2818b398884990af62ab05a401d1f78" -VCS_SHORT_HASH="06731c3" +VCS_FULL_HASH="d03e1acc434f7d0ff8ff910b606229107d8742b8" +VCS_SHORT_HASH="d03e1ac" VCS_WC_MODIFIED="1" |
