mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
daemon mode
This commit is contained in:
@@ -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)
|
||||
-----------
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
struct skynet_config {
|
||||
int thread;
|
||||
int harbor;
|
||||
int daemon;
|
||||
const char * module_path;
|
||||
const char * bootstrap;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user