Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
怡红公子⭕
TDengine
提交
345b1c3a
T
TDengine
项目概览
怡红公子⭕
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
345b1c3a
编写于
5月 19, 2020
作者:
B
Bomin Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ctrl+c handling in taosd
上级
54f671c0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
31 addition
and
8 deletion
+31
-8
src/dnode/src/dnodeSystem.c
src/dnode/src/dnodeSystem.c
+31
-8
未找到文件。
src/dnode/src/dnodeSystem.c
浏览文件 @
345b1c3a
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include "dnodeMain.h"
#include "dnodeMain.h"
static
void
signal_handler
(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
);
static
void
signal_handler
(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
);
static
sem_t
exitSem
;
int32_t
main
(
int32_t
argc
,
char
*
argv
[])
{
int32_t
main
(
int32_t
argc
,
char
*
argv
[])
{
// Set global configuration file
// Set global configuration file
...
@@ -65,6 +66,11 @@ int32_t main(int32_t argc, char *argv[]) {
...
@@ -65,6 +66,11 @@ int32_t main(int32_t argc, char *argv[]) {
#endif
#endif
}
}
if
(
sem_init
(
&
exitSem
,
0
,
0
)
!=
0
)
{
printf
(
"failed to create exit semphore
\n
"
);
exit
(
EXIT_FAILURE
);
}
/* Set termination handler. */
/* Set termination handler. */
struct
sigaction
act
=
{{
0
}};
struct
sigaction
act
=
{{
0
}};
act
.
sa_flags
=
SA_SIGINFO
;
act
.
sa_flags
=
SA_SIGINFO
;
...
@@ -90,9 +96,19 @@ int32_t main(int32_t argc, char *argv[]) {
...
@@ -90,9 +96,19 @@ int32_t main(int32_t argc, char *argv[]) {
syslog
(
LOG_INFO
,
"Started TDengine service successfully."
);
syslog
(
LOG_INFO
,
"Started TDengine service successfully."
);
while
(
1
)
{
for
(
int
res
=
sem_wait
(
&
exitSem
);
res
!=
0
;
res
=
sem_wait
(
&
exitSem
))
{
sleep
(
1000
);
if
(
res
!=
EINTR
)
{
syslog
(
LOG_ERR
,
"failed to wait exit semphore: %d"
,
res
);
break
;
}
}
}
dnodeCleanUpSystem
();
// close the syslog
syslog
(
LOG_INFO
,
"Shut down TDengine service successfully"
);
dPrint
(
"TDengine is shut down!"
);
closelog
();
return
EXIT_SUCCESS
;
}
}
static
void
signal_handler
(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
)
{
static
void
signal_handler
(
int32_t
signum
,
siginfo_t
*
sigInfo
,
void
*
context
)
{
...
@@ -104,14 +120,21 @@ static void signal_handler(int32_t signum, siginfo_t *sigInfo, void *context) {
...
@@ -104,14 +120,21 @@ static void signal_handler(int32_t signum, siginfo_t *sigInfo, void *context) {
taosCfgDynamicOptions
(
"resetlog"
);
taosCfgDynamicOptions
(
"resetlog"
);
return
;
return
;
}
}
syslog
(
LOG_INFO
,
"Shut down signal is %d"
,
signum
);
syslog
(
LOG_INFO
,
"Shut down signal is %d"
,
signum
);
syslog
(
LOG_INFO
,
"Shutting down TDengine service..."
);
syslog
(
LOG_INFO
,
"Shutting down TDengine service..."
);
// clean the system.
// clean the system.
dPrint
(
"shut down signal is %d, sender PID:%d"
,
signum
,
sigInfo
->
si_pid
);
dPrint
(
"shut down signal is %d, sender PID:%d"
,
signum
,
sigInfo
->
si_pid
);
dnodeCleanUpSystem
();
// close the syslog
// protect the application from receive another signal
syslog
(
LOG_INFO
,
"Shut down TDengine service successfully"
);
struct
sigaction
act
=
{{
0
}};
dPrint
(
"TDengine is shut down!"
);
act
.
sa_handler
=
SIG_IGN
;
closelog
();
sigaction
(
SIGTERM
,
&
act
,
NULL
);
exit
(
EXIT_SUCCESS
);
sigaction
(
SIGHUP
,
&
act
,
NULL
);
sigaction
(
SIGINT
,
&
act
,
NULL
);
sigaction
(
SIGUSR1
,
&
act
,
NULL
);
sigaction
(
SIGUSR2
,
&
act
,
NULL
);
// inform main thread to exit
sem_post
(
&
exitSem
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录