Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dapcash-node
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DapCash
dapcash-node
Commits
fe8fd924
Commit
fe8fd924
authored
3 years ago
by
vertuozzo
Browse files
Options
Downloads
Patches
Plain Diff
Correct stop of a node via a KILL (SIGINT, SIGTERM, etc) signal
parent
6d9fa3f9
No related branches found
No related tags found
3 merge requests
!39
bugs-4815
,
!38
feature-4803
,
!37
Correct stop of a node via a KILL (SIGINT, SIGTERM, etc) signal
Pipeline
#7578
passed with stages
in 1 minute and 59 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sources/main.c
+3
-3
3 additions, 3 deletions
sources/main.c
sources/sig_unix_handler.c
+54
-17
54 additions, 17 deletions
sources/sig_unix_handler.c
with
57 additions
and
20 deletions
sources/main.c
+
3
−
3
View file @
fe8fd924
...
...
@@ -493,9 +493,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
();
...
...
This diff is collapsed.
Click to expand it.
sources/sig_unix_handler.c
+
54
−
17
View file @
fe8fd924
#include
<signal.h>
#include
<stdio.h>
#include
<string.h>
#include
<unistd.h>
#include
"dap_common.h"
#include
"dap_file_utils.h"
#include
"dap_events.h"
#include
"dap_chain_global_db.h"
#include
"sig_unix_handler.h"
#define LOG_TAG "sig_unix_handler"
static
const
char
*
l
_pid_path
;
static
const
char
*
s
_pid_path
=
NULL
;
static
void
clear_pid_file
()
{
FILE
*
f
=
fopen
(
l
_pid_path
,
"w"
);
FILE
*
f
=
fopen
(
s
_pid_path
,
"w"
);
if
(
f
==
NULL
)
log_it
(
L_WARNING
,
"Pid file not cleared"
);
else
fclose
(
f
);
}
_Noreturn
static
void
sig_exit_handler
(
int
sig_code
)
{
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_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
);
}
/**
* @brief sig_unix_handler_init
* @param a_pid_path
* @return
*/
int
sig_unix_handler_init
(
const
char
*
a_pid_path
)
int
sig_unix_handler_init
(
const
char
*
a_pid_path
)
{
char
*
l_pid_dir
=
dap_path_get_dirname
(
a_pid_path
);
sleep
(
1
);
dap_mkdir_with_parents
(
l_pid_dir
);
DAP_DELETE
(
l_pid_dir
);
//char * l_pid_dir = dap_path_get_dirname(a_pid_path);
//sleep(1); // Don't know why but without it it crashes O_o
//dap_mkdir_with_parents(l_pid_dir);
//DAP_DELETE(l_pid_dir);
//log_it(L_DEBUG, "Init");
s_pid_path
=
strdup
(
a_pid_path
);
l_pid_path
=
strdup
(
a_pid_path
);
signal
(
SIGINT
,
sig_exit_handler
);
signal
(
SIGTERM
,
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
()
{
free
((
char
*
)
l_pid_path
);
//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
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment