Skip to content

Commit

Permalink
support make install and deb package generate
Browse files Browse the repository at this point in the history
  • Loading branch information
YihaoPeng committed May 11, 2018
1 parent 9b48da2 commit 2879eb4
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 3 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@

# build dir & files
/build*/
/CMakeLists.txt
31 changes: 29 additions & 2 deletions CMakeLists-Default.txt → CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,32 @@ add_executable(unittest ${TEST_SOURCES})
target_link_libraries(unittest btccomagent ${THRID_LIBRARIES})

file(GLOB_RECURSE AGENT_SOURCES src/agent/*.cc)
add_executable(agent ${AGENT_SOURCES})
target_link_libraries(agent btccomagent ${THRID_LIBRARIES})
add_executable(btcagent ${AGENT_SOURCES})
target_link_libraries(btcagent btccomagent ${THRID_LIBRARIES})


# make instal support
install(TARGETS btcagent
DESTINATION /usr/bin)
install(FILES src/agent/agent_conf.json README.md README-zh_CN.md
DESTINATION /etc/btcagent)
install(FILES install/btcagent-single_user.conf
DESTINATION /etc/supervisor/conf.d)

# generate deb package by CPack
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_NAME "btcagent-single_user")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "YihaoPeng [email protected]")

SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/install/debian-control/postinst")

# version
SET(CPACK_PACKAGE_VERSION_MAJOR "1")
SET(CPACK_PACKAGE_VERSION_MINOR "0")
SET(CPACK_PACKAGE_VERSION_PATCH "0")

# dependencies
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "supervisor")

include(CPack)
11 changes: 11 additions & 0 deletions install/btcagent-single_user.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[program:btcagent]
directory=/var/log/btcagent
command=/usr/bin/btcagent -c /etc/btcagent/agent_conf.json -l /var/log/btcagent
autostart=true
autorestart=true
startsecs=3
startretries=2147483647

redirect_stderr=true
stdout_logfile_backups=5
stdout_logfile=/var/log/btcagent/agent_stdout.log
30 changes: 30 additions & 0 deletions install/debian-control/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

echo "-- create log dir for btcagent"
mkdir /var/log/btcagent

echo "-- set minfds=65535 in supervisor.conf"
cat /etc/supervisor/supervisord.conf | grep -v 'minfds\s*=' | sed '/\[supervisord\]/a\minfds=65535' | tee /etc/supervisor/supervisord.conf | grep 'minfds\s*='

echo "-- start supervisor & running btcagent"
service supervisor start
echo "-- start btcagent"
supervisorctl reread
supervisorctl update
supervisorctl status btcagent

echo "-- Install successfully."
echo # empty line
echo "-- Usage:"
echo "* Edit config file:"
echo " vim /etc/btcagent/agent_conf.json"
echo "* Start supervisor (daemon service of btcagent)"
echo " service start supervisor"
echo "* Restart btcagent:"
echo " supervisorctl restart btcagent"
echo "* Stop btcagent:"
echo " supervisorctl stop btcagent"
echo "* Show logs:"
echo " tail -F /var/log/btcagent/*INFO"
echo "* Count connections:"
echo " netstat -antp | grep btcagent"

0 comments on commit 2879eb4

Please sign in to comment.