diff --git a/include/server/dnode/dnode.h b/include/server/dnode/dnode.h
index 08658f3542..76a3d3ea1b 100644
--- a/include/server/dnode/dnode.h
+++ b/include/server/dnode/dnode.h
@@ -32,7 +32,7 @@ struct Dnode *dnodeCreateInstance();
*
* @param dnode, instance of dnode module.
*/
-void dnodeCleanupInstance(struct Dnode *dnode);
+void dnodeDropInstance(struct Dnode *dnode);
/**
* Send messages to other dnodes, such as create vnode message.
diff --git a/include/server/mnode/mnode.h b/include/server/mnode/mnode.h
index f6c067f784..7a06880a16 100644
--- a/include/server/mnode/mnode.h
+++ b/include/server/mnode/mnode.h
@@ -82,7 +82,7 @@ struct Mnode *mnodeCreateInstance(SMnodePara para);
*
* @param mnode, instance of mnode module.
*/
-void mnodeCleanupInstance(struct Mnode *vnode);
+void mnodeDropInstance(struct Mnode *vnode);
/**
* Deploy mnode instances in dnode.
diff --git a/include/server/vnode/vnode.h b/include/server/vnode/vnode.h
index 8aebd5aa9b..ee015788d3 100644
--- a/include/server/vnode/vnode.h
+++ b/include/server/vnode/vnode.h
@@ -71,7 +71,7 @@ struct Vnode *vnodeCreateInstance(SVnodePara para);
*
* @param vnode, instance of vnode module.
*/
-void vnodeCleanupInstance(struct Vnode *vnode);
+void vnodeDropInstance(struct Vnode *vnode);
typedef struct {
int32_t unused;
diff --git a/source/os/CMakeLists.txt b/source/os/CMakeLists.txt
index 9e5d6126ba..0eda9d637d 100644
--- a/source/os/CMakeLists.txt
+++ b/source/os/CMakeLists.txt
@@ -4,4 +4,11 @@ target_include_directories(
os
PUBLIC "${CMAKE_SOURCE_DIR}/include/os"
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include"
+)
+target_link_libraries(
+ os
+ PUBLIC pthread
+ PUBLIC dl
+ PUBLIC rt
+ PUBLIC m
)
\ No newline at end of file
diff --git a/source/server/CMakeLists.txt b/source/server/CMakeLists.txt
index d80c7876db..1f6da54ebe 100644
--- a/source/server/CMakeLists.txt
+++ b/source/server/CMakeLists.txt
@@ -7,5 +7,5 @@ aux_source_directory(. TAOSD_SRC)
add_executable(taosd ${TAOSD_SRC})
target_link_libraries(
taosd
- PUBLIC os
+ PUBLIC dnode
)
\ No newline at end of file
diff --git a/source/server/dnode/CMakeLists.txt b/source/server/dnode/CMakeLists.txt
index cf7482eca6..e627ca94e8 100644
--- a/source/server/dnode/CMakeLists.txt
+++ b/source/server/dnode/CMakeLists.txt
@@ -2,11 +2,7 @@ aux_source_directory(src DNODE_SRC)
add_library(dnode ${DNODE_SRC})
target_link_libraries(
dnode
- PUBLIC os
PUBLIC cjson
- PUBLIC util
- PUBLIC common
- PUBLIC transport
PUBLIC mnode
PUBLIC vnode
)
diff --git a/source/server/dnode/src/dnodeInt.c b/source/server/dnode/src/dnodeInt.c
index 2f805bb882..f38d9665ac 100644
--- a/source/server/dnode/src/dnodeInt.c
+++ b/source/server/dnode/src/dnodeInt.c
@@ -65,7 +65,7 @@ static int32_t dnodeInitVnodeModule(Dnode *dnode, struct Vnode** out) {
static void dnodeCleanupVnodeModule(Dnode *dnode, struct Vnode **out) {
struct Vnode *vnode = *out;
*out = NULL;
- vnodeCleanupInstance(vnode);
+ vnodeDropInstance(vnode);
}
static int32_t dnodeInitMnodeModule(Dnode *dnode, struct Mnode **out) {
@@ -90,7 +90,7 @@ static int32_t dnodeInitMnodeModule(Dnode *dnode, struct Mnode **out) {
static void dnodeCleanupMnodeModule(Dnode *dnode, struct Mnode **out) {
struct Mnode *mnode = *out;
*out = NULL;
- mnodeCleanupInstance(mnode);
+ mnodeDropInstance(mnode);
}
Dnode *dnodeCreateInstance() {
@@ -223,7 +223,7 @@ Dnode *dnodeCreateInstance() {
return dnode;
}
-void dnodeCleanupInstance(Dnode *dnode) {
+void dnodeDropInstance(Dnode *dnode) {
if (dnode->main->runStatus != TD_RUN_STAT_STOPPED) {
dnode->main->runStatus = TD_RUN_STAT_STOPPED;
taosStepCleanup(dnode->steps);
diff --git a/source/server/dnode/src/dnodeMain.c b/source/server/dnode/src/dnodeMain.c
index 8836b633e4..7854fe2b4b 100644
--- a/source/server/dnode/src/dnodeMain.c
+++ b/source/server/dnode/src/dnodeMain.c
@@ -112,7 +112,9 @@ void dnodeCleanupMain(DnMain **out) {
main->dnodeTimer = NULL;
}
+#if 0
taos_cleanup();
+#endif
taosCloseLog();
taosStopCacheRefreshWorker();
diff --git a/source/server/mnode/CMakeLists.txt b/source/server/mnode/CMakeLists.txt
index 689d6f7f2a..331a717bf5 100644
--- a/source/server/mnode/CMakeLists.txt
+++ b/source/server/mnode/CMakeLists.txt
@@ -4,4 +4,8 @@ target_include_directories(
mnode
PUBLIC "${CMAKE_SOURCE_DIR}/include/server/mnode"
private "${CMAKE_CURRENT_SOURCE_DIR}/inc"
+)
+target_link_libraries(
+ mnode
+ PUBLIC transport
)
\ No newline at end of file
diff --git a/source/server/mnode/inc/mnodeInt.h b/source/server/mnode/inc/mnodeInt.h
index 60b748f0ea..646331b076 100644
--- a/source/server/mnode/inc/mnodeInt.h
+++ b/source/server/mnode/inc/mnodeInt.h
@@ -20,6 +20,11 @@
extern "C" {
#endif
+#include "os.h"
+#include "taosmsg.h"
+#include "trpc.h"
+#include "mnode.h"
+
#ifdef __cplusplus
}
#endif
diff --git a/source/server/vnode/src/vnode.c b/source/server/mnode/src/mnodeMain.c
similarity index 50%
rename from source/server/vnode/src/vnode.c
rename to source/server/mnode/src/mnodeMain.c
index 6dea4a4e57..3747534e36 100644
--- a/source/server/vnode/src/vnode.c
+++ b/source/server/mnode/src/mnodeMain.c
@@ -11,4 +11,26 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
- */
\ No newline at end of file
+ */
+
+#include "mnodeInt.h"
+
+struct Mnode *mnodeCreateInstance(SMnodePara para) {
+ return NULL;
+}
+
+void mnodeDropInstance(struct Mnode *vnode) {}
+
+int32_t mnodeDeploy(struct Mnode *mnode, struct SMInfos *minfos) { return 0; }
+
+void mnodeUnDeploy(struct Mnode *mnode) {}
+
+bool mnodeIsServing(struct Mnode *mnode) { return false; }
+
+int32_t mnodeGetStatistics(struct Mnode *mnode, SMnodeStat *stat) { return 0; }
+
+int32_t mnodeRetriveAuth(struct Mnode *mnode, char *user, char *spi, char *encrypt, char *secret, char *ckey) {
+ return 0;
+}
+
+void mnodeProcessMsg(struct Mnode *mnode, SRpcMsg *rpcMsg) {}
diff --git a/source/server/main.c b/source/server/server.c
similarity index 59%
rename from source/server/main.c
rename to source/server/server.c
index 75449ecd1a..b5c8992b65 100644
--- a/source/server/main.c
+++ b/source/server/server.c
@@ -13,8 +13,25 @@
* along with this program. If not, see .
*/
#include "os.h"
+#include "tulog.h"
+#include "trpc.h"
+#include "dnode.h"
int main(int argc, char const *argv[]) {
- printf("Hello world!\n");
+ struct Dnode *dnode = dnodeCreateInstance();
+ if (dnode == NULL) {
+ uInfo("Failed to start TDengine, please check the log at:%s", tsLogDir);
+ exit(EXIT_FAILURE);
+ }
+
+ uInfo("Started TDengine service successfully.");
+
+ // if (tsem_wait(&exitSem) != 0) {
+ // syslog(LOG_ERR, "failed to wait exit semphore: %s", strerror(errno));
+ // }
+
+ dnodeDropInstance(dnode);
+
+ uInfo("TDengine is shut down!");
return 0;
}
diff --git a/source/server/vnode/CMakeLists.txt b/source/server/vnode/CMakeLists.txt
index 75d24ed64e..03421b2628 100644
--- a/source/server/vnode/CMakeLists.txt
+++ b/source/server/vnode/CMakeLists.txt
@@ -9,9 +9,10 @@ target_include_directories(
PUBLIC "${CMAKE_SOURCE_DIR}/include/server/vnode"
private "${CMAKE_CURRENT_SOURCE_DIR}/inc"
)
-target_include_directories(
+target_link_libraries(
vnode
- PRIVATE meta
- PRIVATE tq
- PRIVATE tsdb
+ PUBLIC transport
+ PUBLIC meta
+ PUBLIC tq
+ PUBLIC tsdb
)
\ No newline at end of file
diff --git a/source/server/vnode/inc/vnodeInt.h b/source/server/vnode/inc/vnodeInt.h
index 855eb66c8a..12568d21b8 100644
--- a/source/server/vnode/inc/vnodeInt.h
+++ b/source/server/vnode/inc/vnodeInt.h
@@ -20,6 +20,11 @@
extern "C" {
#endif
+#include "os.h"
+#include "taosmsg.h"
+#include "trpc.h"
+#include "vnode.h"
+
#ifdef __cplusplus
}
#endif
diff --git a/source/server/mnode/src/mnode.c b/source/server/vnode/src/vnodeMain.c
similarity index 57%
rename from source/server/mnode/src/mnode.c
rename to source/server/vnode/src/vnodeMain.c
index 6dea4a4e57..0f26041787 100644
--- a/source/server/mnode/src/mnode.c
+++ b/source/server/vnode/src/vnodeMain.c
@@ -11,4 +11,20 @@
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
- */
\ No newline at end of file
+ */
+
+#include "vnodeInt.h"
+
+struct Vnode *vnodeCreateInstance(SVnodePara para) {
+ return NULL;
+}
+
+void vnodeDropInstance(struct Vnode *vnode) {}
+
+int32_t vnodeGetStatistics(struct Vnode *vnode, SVnodeStat *stat) { return 0; }
+
+void vnodeGetStatus(struct Vnode *vnode, struct SStatusMsg *status) {}
+
+void vnodeSetAccess(struct Vnode *vnode, struct SVgroupAccess *access, int32_t numOfVnodes) {}
+
+void vnodeProcessMsg(struct Vnode *vnode, SRpcMsg *msg) {}
diff --git a/source/util/src/tstep.c b/source/util/src/tstep.c
new file mode 100644
index 0000000000..97cd3290da
--- /dev/null
+++ b/source/util/src/tstep.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2019 TAOS Data, Inc.
+ *
+ * This program is free software: you can use, redistribute, and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3
+ * or later ("AGPL"), as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+#define _DEFAULT_SOURCE
+#include "os.h"
+#include "tulog.h"
+#include "tstep.h"
+
+SSteps *taosStepInit(int32_t maxsize) {
+ SSteps *steps = calloc(1, sizeof(SSteps));
+ if (steps == NULL) return NULL;
+
+ steps->maxsize = maxsize;
+ steps->cursize = 0;
+ steps->steps = calloc(maxsize, sizeof(SStepObj));
+
+ return steps;
+}
+
+int32_t taosStepAdd(SSteps *steps, SStepObj *step) {
+ if (steps == NULL) return - 1;
+
+ if (steps->cursize >= steps->maxsize) {
+ uError("failed to add step since up to the maxsize");
+ return -1;
+ }
+
+ steps->steps[steps->cursize++] = *step;
+ return 0;
+}
+
+static void taosStepCleanupImp(SSteps *steps, int32_t pos) {
+ for (int32_t s = pos; s >= 0; s--) {
+ SStepObj *step = steps->steps + s;
+ uDebug("step:%s will cleanup", step->name);
+ if (step->cleanupFp != NULL) {
+ (*step->cleanupFp)(step->self);
+ }
+ }
+}
+
+int32_t taosStepExec(SSteps *steps) {
+ if (steps == NULL) return -1;
+
+ for (int32_t s = 0; s < steps->cursize; s++) {
+ SStepObj *step = steps->steps + s;
+ if (step->initFp == NULL) continue;
+
+ if (step->reportFp != NULL) {
+ (*step->reportFp)(step->parent, step->name, "start initialize");
+ }
+
+ int32_t code = (*step->initFp)(step->parent, step->self);
+ if (code != 0) {
+ uDebug("step:%s will cleanup", step->name);
+ taosStepCleanupImp(steps, s);
+ return code;
+ }
+
+ uInfo("step:%s is initialized", step->name);
+
+ if (step->reportFp != NULL) {
+ (*step->reportFp)(step->parent, step->name, "initialize completed");
+ }
+ }
+
+ return 0;
+}
+
+void taosStepCleanup(SSteps *steps) {
+ if (steps == NULL) return;
+ taosStepCleanupImp(steps, steps->cursize - 1);
+}
\ No newline at end of file