diff --git a/CMakeLists.txt b/CMakeLists.txt index f6219e9ea6e3c90e7b46cfce5cc460b11e7c619f..71c367521422fc844623881190bab0f1dbabb7a6 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 4) -SET( CPACK_PACKAGE_VERSION_PATCH 3) +SET( CPACK_PACKAGE_VERSION_PATCH 4) # init CellFrame SDK add_definitions("-DDAP_VERSION=\"${CPACK_PACKAGE_VERSION_MAJOR}-${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}\"") 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/sig_unix_handler.c b/sources/sig_unix_handler.c index 476e339df21a1599bb1e30a6b120b71e56d8ad13..dd56e2d870e8ced973c28b0db8053121e00e45fc 100644 --- a/sources/sig_unix_handler.c +++ b/sources/sig_unix_handler.c @@ -21,9 +21,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 +58,31 @@ 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((void *)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; } +