mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
daemon mode
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
Dev version
|
Dev version
|
||||||
-----------
|
-----------
|
||||||
* Bugfix: update lua-bson (signed 32bit int bug)
|
* Bugfix: update lua-bson (signed 32bit int bug)
|
||||||
* cluster support
|
* Add cluster support
|
||||||
|
* Add daemon mode
|
||||||
|
|
||||||
v0.2.1 (2014-5-19)
|
v0.2.1 (2014-5-19)
|
||||||
-----------
|
-----------
|
||||||
|
|||||||
@@ -12,3 +12,4 @@ lualoader = "lualib/loader.lua"
|
|||||||
-- preload = "./examples/preload.lua" -- run preload.lua before every lua service run
|
-- preload = "./examples/preload.lua" -- run preload.lua before every lua service run
|
||||||
snax = root.."examples/?.lua;"..root.."test/?.lua"
|
snax = root.."examples/?.lua;"..root.."test/?.lua"
|
||||||
cpath = root.."cservice/?.so"
|
cpath = root.."cservice/?.so"
|
||||||
|
daemon = false
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
struct skynet_config {
|
struct skynet_config {
|
||||||
int thread;
|
int thread;
|
||||||
int harbor;
|
int harbor;
|
||||||
|
int daemon;
|
||||||
const char * module_path;
|
const char * module_path;
|
||||||
const char * bootstrap;
|
const char * bootstrap;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ optint(const char *key, int opt) {
|
|||||||
return strtol(str, NULL, 10);
|
return strtol(str, NULL, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
static int
|
static int
|
||||||
optboolean(const char *key, int opt) {
|
optboolean(const char *key, int opt) {
|
||||||
const char * str = skynet_getenv(key);
|
const char * str = skynet_getenv(key);
|
||||||
@@ -34,7 +33,7 @@ optboolean(const char *key, int opt) {
|
|||||||
}
|
}
|
||||||
return strcmp(str,"true")==0;
|
return strcmp(str,"true")==0;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
static const char *
|
static const char *
|
||||||
optstring(const char *key,const char * opt) {
|
optstring(const char *key,const char * opt) {
|
||||||
const char * str = skynet_getenv(key);
|
const char * str = skynet_getenv(key);
|
||||||
@@ -109,21 +108,16 @@ main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
_init_env(L);
|
_init_env(L);
|
||||||
|
|
||||||
#ifdef LUA_CACHELIB
|
|
||||||
printf("Skynet lua code cache enable\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
config.thread = optint("thread",8);
|
config.thread = optint("thread",8);
|
||||||
config.module_path = optstring("cpath","./cservice/?.so");
|
config.module_path = optstring("cpath","./cservice/?.so");
|
||||||
config.harbor = optint("harbor", 1);
|
config.harbor = optint("harbor", 1);
|
||||||
config.bootstrap = optstring("bootstrap","snlua bootstrap");
|
config.bootstrap = optstring("bootstrap","snlua bootstrap");
|
||||||
|
config.daemon = optboolean("daemon", 0);
|
||||||
|
|
||||||
lua_close(L);
|
lua_close(L);
|
||||||
|
|
||||||
skynet_start(&config);
|
skynet_start(&config);
|
||||||
skynet_globalexit();
|
skynet_globalexit();
|
||||||
|
|
||||||
printf("skynet exit\n");
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,6 +195,12 @@ bootstrap(const char * cmdline) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
skynet_start(struct skynet_config * config) {
|
skynet_start(struct skynet_config * config) {
|
||||||
|
if (config->daemon) {
|
||||||
|
if (daemon(1,0)) {
|
||||||
|
fprintf(stderr, "daemon error");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
skynet_harbor_init(config->harbor);
|
skynet_harbor_init(config->harbor);
|
||||||
skynet_handle_init(config->harbor);
|
skynet_handle_init(config->harbor);
|
||||||
skynet_mq_init();
|
skynet_mq_init();
|
||||||
|
|||||||
Reference in New Issue
Block a user