Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
94bbd38b
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
94bbd38b
编写于
6月 04, 2020
作者:
S
Shengliang Guan
提交者:
GitHub
6月 04, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2135 from taosdata/hotfix/TD-476
Hotfix/td-476
上级
3c7b4637
fe5ebec9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
37 addition
and
10 deletion
+37
-10
src/dnode/src/dnodeMain.c
src/dnode/src/dnodeMain.c
+37
-10
未找到文件。
src/dnode/src/dnodeMain.c
浏览文件 @
94bbd38b
...
@@ -38,6 +38,7 @@ static void dnodeCheckDataDirOpenned(char *dir);
...
@@ -38,6 +38,7 @@ static void dnodeCheckDataDirOpenned(char *dir);
static
SDnodeRunStatus
tsDnodeRunStatus
=
TSDB_DNODE_RUN_STATUS_STOPPED
;
static
SDnodeRunStatus
tsDnodeRunStatus
=
TSDB_DNODE_RUN_STATUS_STOPPED
;
static
int32_t
dnodeInitComponents
();
static
int32_t
dnodeInitComponents
();
static
void
dnodeCleanupComponents
(
int32_t
stepId
);
static
void
dnodeCleanupComponents
(
int32_t
stepId
);
static
int
dnodeCreateDir
(
const
char
*
dir
);
typedef
struct
{
typedef
struct
{
const
char
*
const
name
;
const
char
*
const
name
;
...
@@ -59,6 +60,16 @@ static const SDnodeComponent SDnodeComponents[] = {
...
@@ -59,6 +60,16 @@ static const SDnodeComponent SDnodeComponents[] = {
{
"shell"
,
dnodeInitShell
,
dnodeCleanupShell
}
{
"shell"
,
dnodeInitShell
,
dnodeCleanupShell
}
};
};
static
int
dnodeCreateDir
(
const
char
*
dir
)
{
struct
stat
dirstat
;
if
(
stat
(
dir
,
&
dirstat
)
<
0
)
{
if
(
mkdir
(
dir
,
0755
)
!=
0
&&
errno
!=
EEXIST
)
{
return
-
1
;
}
}
return
0
;
}
static
void
dnodeCleanupComponents
(
int32_t
stepId
)
{
static
void
dnodeCleanupComponents
(
int32_t
stepId
)
{
for
(
int32_t
i
=
stepId
;
i
>=
0
;
i
--
)
{
for
(
int32_t
i
=
stepId
;
i
>=
0
;
i
--
)
{
SDnodeComponents
[
i
].
cleanup
();
SDnodeComponents
[
i
].
cleanup
();
...
@@ -87,9 +98,9 @@ int32_t dnodeInitSystem() {
...
@@ -87,9 +98,9 @@ int32_t dnodeInitSystem() {
taosSetCoreDump
();
taosSetCoreDump
();
signal
(
SIGPIPE
,
SIG_IGN
);
signal
(
SIGPIPE
,
SIG_IGN
);
struct
stat
dirstat
;
if
(
dnodeCreateDir
(
tsLogDir
)
<
0
)
{
if
(
stat
(
tsLogDir
,
&
dirstat
)
<
0
)
{
printf
(
"failed to create dir: %s, reason: %s
\n
"
,
tsLogDir
,
strerror
(
errno
));
mkdir
(
tsLogDir
,
0755
)
;
return
-
1
;
}
}
char
temp
[
TSDB_FILENAME_LEN
];
char
temp
[
TSDB_FILENAME_LEN
];
...
@@ -140,7 +151,11 @@ static void dnodeCheckDataDirOpenned(char *dir) {
...
@@ -140,7 +151,11 @@ static void dnodeCheckDataDirOpenned(char *dir) {
char
filepath
[
256
]
=
{
0
};
char
filepath
[
256
]
=
{
0
};
sprintf
(
filepath
,
"%s/.running"
,
dir
);
sprintf
(
filepath
,
"%s/.running"
,
dir
);
int32_t
fd
=
open
(
filepath
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
int
fd
=
open
(
filepath
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
S_IRWXU
|
S_IRWXG
|
S_IRWXO
);
if
(
fd
<
0
)
{
dError
(
"failed to open lock file:%s, reason: %s, quit"
,
filepath
,
strerror
(
errno
));
exit
(
0
);
}
int32_t
ret
=
flock
(
fd
,
LOCK_EX
|
LOCK_NB
);
int32_t
ret
=
flock
(
fd
,
LOCK_EX
|
LOCK_NB
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
dError
(
"failed to lock file:%s ret:%d, database may be running, quit"
,
filepath
,
ret
);
dError
(
"failed to lock file:%s ret:%d, database may be running, quit"
,
filepath
,
ret
);
...
@@ -150,16 +165,28 @@ static void dnodeCheckDataDirOpenned(char *dir) {
...
@@ -150,16 +165,28 @@ static void dnodeCheckDataDirOpenned(char *dir) {
}
}
static
int32_t
dnodeInitStorage
()
{
static
int32_t
dnodeInitStorage
()
{
struct
stat
dirstat
;
if
(
dnodeCreateDir
(
tsDataDir
)
<
0
)
{
if
(
stat
(
tsDataDir
,
&
dirstat
)
<
0
)
{
dError
(
"failed to create dir: %s, reason: %s"
,
tsDataDir
,
strerror
(
errno
));
mkdir
(
tsDataDir
,
0755
)
;
return
-
1
;
}
}
sprintf
(
tsMnodeDir
,
"%s/mnode"
,
tsDataDir
);
sprintf
(
tsMnodeDir
,
"%s/mnode"
,
tsDataDir
);
sprintf
(
tsVnodeDir
,
"%s/vnode"
,
tsDataDir
);
sprintf
(
tsVnodeDir
,
"%s/vnode"
,
tsDataDir
);
sprintf
(
tsDnodeDir
,
"%s/dnode"
,
tsDataDir
);
sprintf
(
tsDnodeDir
,
"%s/dnode"
,
tsDataDir
);
mkdir
(
tsVnodeDir
,
0755
);
mkdir
(
tsDnodeDir
,
0755
);
//TODO(dengyihao): no need to init here
if
(
dnodeCreateDir
(
tsMnodeDir
)
<
0
)
{
dError
(
"failed to create dir: %s, reason: %s"
,
tsMnodeDir
,
strerror
(
errno
));
return
-
1
;
}
//TODO(dengyihao): no need to init here
if
(
dnodeCreateDir
(
tsVnodeDir
)
<
0
)
{
dError
(
"failed to create dir: %s, reason: %s"
,
tsVnodeDir
,
strerror
(
errno
));
return
-
1
;
}
if
(
dnodeCreateDir
(
tsDnodeDir
)
<
0
)
{
dError
(
"failed to create dir: %s, reason: %s"
,
tsDnodeDir
,
strerror
(
errno
));
return
-
1
;
}
dnodeCheckDataDirOpenned
(
tsDnodeDir
);
dnodeCheckDataDirOpenned
(
tsDnodeDir
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录