daemon mode

This commit is contained in:
Cloud Wu
2014-05-23 10:54:54 +08:00
parent 37ea7a025c
commit 1ce90b7d17
5 changed files with 12 additions and 9 deletions

View File

@@ -1,7 +1,8 @@
Dev version
-----------
* Bugfix: update lua-bson (signed 32bit int bug)
* cluster support
* Add cluster support
* Add daemon mode
v0.2.1 (2014-5-19)
-----------

View File

@@ -12,3 +12,4 @@ lualoader = "lualib/loader.lua"
-- preload = "./examples/preload.lua" -- run preload.lua before every lua service run
snax = root.."examples/?.lua;"..root.."test/?.lua"
cpath = root.."cservice/?.so"
daemon = false

View File

@@ -4,6 +4,7 @@
struct skynet_config {
int thread;
int harbor;
int daemon;
const char * module_path;
const char * bootstrap;
};

View File

@@ -24,7 +24,6 @@ optint(const char *key, int opt) {
return strtol(str, NULL, 10);
}
/*
static int
optboolean(const char *key, int opt) {
const char * str = skynet_getenv(key);
@@ -34,7 +33,7 @@ optboolean(const char *key, int opt) {
}
return strcmp(str,"true")==0;
}
*/
static const char *
optstring(const char *key,const char * opt) {
const char * str = skynet_getenv(key);
@@ -109,21 +108,16 @@ main(int argc, char *argv[]) {
}
_init_env(L);
#ifdef LUA_CACHELIB
printf("Skynet lua code cache enable\n");
#endif
config.thread = optint("thread",8);
config.module_path = optstring("cpath","./cservice/?.so");
config.harbor = optint("harbor", 1);
config.bootstrap = optstring("bootstrap","snlua bootstrap");
config.daemon = optboolean("daemon", 0);
lua_close(L);
skynet_start(&config);
skynet_globalexit();
printf("skynet exit\n");
return 0;
}

View File

@@ -195,6 +195,12 @@ bootstrap(const char * cmdline) {
void
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_handle_init(config->harbor);
skynet_mq_init();