diff --git a/CMakeLists.txt b/CMakeLists.txt index ffdcfb0985cd7451ac322e7bd5eee464597e7daf..67316c1b822b4b6dcd14a3b3d4d0ce4b11941e20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ set(CMAKE_C_STANDARD 11) SET( CPACK_PACKAGE_NAME "${PROJECT_NAME}") SET( CPACK_PACKAGE_VERSION_MAJOR 4) SET( CPACK_PACKAGE_VERSION_MINOR 3) -SET( CPACK_PACKAGE_VERSION_PATCH 46) +SET( CPACK_PACKAGE_VERSION_PATCH 52) # init CellFrame SDK add_definitions("-DDAP_VERSION=\"${CPACK_PACKAGE_VERSION_MAJOR}-${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}\"") diff --git a/cellframe-sdk b/cellframe-sdk index 01bcfa7825e605f04dcfb1317482440e3dd99d43..f5f5c730dc640e5fa3fb156ced3baa6a06e799cb 160000 --- a/cellframe-sdk +++ b/cellframe-sdk @@ -1 +1 @@ -Subproject commit 01bcfa7825e605f04dcfb1317482440e3dd99d43 +Subproject commit f5f5c730dc640e5fa3fb156ced3baa6a06e799cb diff --git a/dist.linux/share/cellframe-node.service b/dist.linux/share/cellframe-node.service index 34c0fd54df28ed4052057145c7b033d19e7525eb..7516a32a08d3685680915aedf24dfba7626125e9 100644 --- a/dist.linux/share/cellframe-node.service +++ b/dist.linux/share/cellframe-node.service @@ -8,7 +8,8 @@ After=network.target #PIDFile=/opt/cellframe-node/var/run/cellframe-node.pid WorkingDirectory=/opt/cellframe-node ExecStart=/opt/cellframe-node/bin/cellframe-node & -ExecStop=/opt/cellframe-node/bin/cellframe-node --stop +#ExecStop=/opt/cellframe-node/bin/cellframe-node --stop +ExecStop=/bin/kill -SIGTERM $MAINPID Restart=always #User=cellframe-node #Group=cellframe-node diff --git a/sources/main.c b/sources/main.c index ea362bba1a20d1a56a52bc79bce5397de4c1f016..0a7368303e8c976edad17366c3dbbb2776f28a0d 100755 --- a/sources/main.c +++ b/sources/main.c @@ -496,9 +496,9 @@ int main( int argc, const char **argv ) //failure: - #ifdef DAP_SUPPORT_PYTHON_PLUGINS - dap_chain_plugins_deinit(); - #endif +// #ifdef DAP_SUPPORT_PYTHON_PLUGINS +// dap_chain_plugins_deinit(); +// #endif dap_dns_server_stop(); dap_stream_deinit(); dap_stream_ctl_deinit(); diff --git a/sources/sig_unix_handler.c b/sources/sig_unix_handler.c index 3d92f42057d151f6d55857ee50c10399e6f60e66..4c900b0c6fdc4b50b38267d0eea53e4fae8f48c9 100644 --- a/sources/sig_unix_handler.c +++ b/sources/sig_unix_handler.c @@ -1,6 +1,7 @@ #include <signal.h> #include <stdio.h> #include <string.h> +#include <unistd.h> #include "dap_common.h" #include "dap_events.h" @@ -21,9 +22,33 @@ static void clear_pid_file() { static void sig_exit_handler(int sig_code) { log_it(L_DEBUG, "Got exit code: %d", sig_code); + clear_pid_file(); + +//#ifdef DAP_SUPPORT_PYTHON_PLUGINS +// dap_chain_plugins_deinit(); +//#endif + dap_chain_node_mempool_autoproc_deinit(); + dap_chain_net_srv_xchange_deinit(); + dap_chain_net_srv_stake_deinit(); + dap_chain_net_deinit(); dap_chain_global_db_deinit(); - //dap_events_stop_all(); + dap_chain_deinit(); + dap_stream_ctl_deinit(); + dap_stream_deinit(); + dap_enc_ks_deinit(); + enc_http_deinit(); + dap_http_deinit(); + dap_dns_server_stop(); + dap_server_deinit(); + dap_events_stop_all(); + dap_events_deinit(); + dap_config_close( g_config ); + dap_common_deinit(); + + //log_it(L_NOTICE,"Stopped Cellframe Node"); + //fflush(stdout); + exit(0); } @@ -34,22 +59,30 @@ int sig_unix_handler_init(const char *a_pid_path) //dap_mkdir_with_parents(l_pid_dir); //DAP_DELETE(l_pid_dir); + //log_it(L_DEBUG, "Init"); + s_pid_path = strdup(a_pid_path); - - struct sigaction new_action, old_action; - new_action.sa_handler = sig_exit_handler; - new_action.sa_flags = 0; - sigaction(SIGTERM, &new_action, &old_action); - sigaction(SIGINT, &new_action, &old_action); - sigaction(SIGHUP, &new_action, &old_action); + + signal(SIGINT, sig_exit_handler); + signal(SIGHUP, sig_exit_handler); + signal(SIGTERM, sig_exit_handler); + signal(SIGQUIT, sig_exit_handler); + signal(SIGTSTP, sig_exit_handler); + return 0; } int sig_unix_handler_deinit() { + //log_it(L_DEBUG, "Deinit"); + if( s_pid_path ) DAP_DELETE(s_pid_path); + signal(SIGTERM, SIG_DFL); signal(SIGINT, SIG_DFL); signal(SIGHUP, SIG_DFL); + signal(SIGQUIT, SIG_DFL); + signal(SIGTSTP, SIG_DFL); + return 0; }