bool Schema::load_schema(TiXmlElement *root_node) { if(NULL == root_node) { Log::get_instance().log().error("schemas element is NULL."); return false; } TiXmlElement *schema_element = root_node->FirstChildElement("Schema"); while(NULL != schema_element) { SchemaServer server; if(false == load_server(schema_element, server)) { Log::get_instance().log().error("load server element failure."); return false; } if(false == load_databases(schema_element, server)) { Log::get_instance().log().error("load databases element failure."); return false; } schema_server_sets.insert(std::pair<int, SchemaServer>(server.id, server)); schema_element = schema_element->NextSiblingElement("Schema"); } return true; }
void taskmain(int argc, char **argv) { L = luaL_newstate(); dbg_set_log(stderr); int rc = 0; check(argc == 3, "usage: mongrel2 config.lua server_name"); //if(argc == 4) { // log_info("Using configuration module %s to load configs.", argv[3]); // rc = Config_module_load(argv[3]); // check(rc != -1, "Failed to load the config module: %s", argv[3]); //} Server_queue_init(); Server *srv = load_server(L, argv[1], argv[2], NULL); check(srv != NULL, "Aborting since can't load server."); Server_queue_push(srv); SuperPoll_get_max_fd(); // rc = clear_pid_file(srv); // check(rc == 0, "PID file failure, aborting rather than trying to start."); // rc = attempt_chroot_drop(srv); // check(rc == 0, "Major failure in chroot/droppriv, aborting."); final_setup(); taskcreate(tickertask, NULL, TICKER_TASK_STACK); struct ServerTask *srv_data = calloc(1, sizeof(struct ServerTask)); srv_data->db_file = bfromcstr(argv[1]); srv_data->server_id = bfromcstr(argv[2]); // taskcreate(reload_task, srv_data, RELOAD_TASK_STACK); rc = Server_run(); check(rc != -1, "Server had a failure and exited early."); log_info("Server run exited, goodbye."); srv = Server_queue_latest(); complete_shutdown(srv); return; error: log_err("Exiting due to error."); taskexitall(1); }
Server *reload_server(lua_State *L, Server *old_srv, const char *config_file, const char *server_name) { log_info("------------------------ RELOAD %s -----------------------------------", server_name); MIME_destroy(); Setting_destroy(); Server *srv = load_server(L, config_file, server_name, old_srv); check(srv != NULL, "Failed to load new server config."); Server_stop_handlers(old_srv); RELOAD = 0; return srv; error: return NULL; }
Server *reload_server(Server *old_srv, const char *db_file, const char *server_uuid) { log_info("------------------------ RELOAD %s -----------------------------------", server_uuid); MIME_destroy(); Setting_destroy(); Server *srv = load_server(db_file, server_uuid, old_srv); check(srv != NULL, "Failed to load new server config."); Server_stop_handlers(old_srv); rotate_logs(); RELOAD = 0; return srv; error: return NULL; }
int main(int argc, char **argv) { int i,serverid=0; FILE *fp=NULL,*fpscript=fopen(INND_SCRIPT,"w"); char buf[256],serverstr[30]=""; chdir(BBSHOME "/innd"); attach_SHM(); resolve_boards(); memset(istran,0,sizeof(int)*MAX_BOARD); load_server(); load_newsfeeds(); for(i=0;i<feedcount;i++) { if(strcasecmp(serverstr,feedline[i].server)) { if(get_server(feedline[i].server)==-1) continue; if(fp) { fclose(fp); dobbsnnrp(serverstr,serverid,fpscript); } strcpy(serverstr,feedline[i].server); serverid=get_server(feedline[i].server); sprintf(buf,INNDHOME"/active/%s.auto.active",serverstr); fp=fopen(buf,"w"); } if(fp) fprintf(fp,"%-35s 0000000000 0000000000 y\r\n",feedline[i].group); } if(fp) { dobbsnnrp(serverstr,serverid,fpscript); fclose(fp); } if(fpscript) { fclose(fpscript); chmod(INND_SCRIPT,0744); } // 重設轉信與不轉信板標記 int total = num_boards(); for(i=0;i<total;i++) { if(bcache[i].brdname[0]=='\0' || (bcache[i].brdattr & BRD_GROUPBOARD) ) continue; if((bcache[i].brdattr & BRD_NOTRAN )&& istran[i]) { while(SHM->Bbusystate) {safe_sleep(1);} SHM->Bbusystate = 1; bcache[i].brdattr = bcache[i].brdattr & ~BRD_NOTRAN; strncpy(bcache[i].title + 5, "●", 2); SHM->Bbusystate = 0; substitute_record(BBSHOME"/.BRD", &bcache[i],sizeof(boardheader_t),i+1); } else if(!(bcache[i].brdattr & BRD_NOTRAN) && !istran[i]) { while(SHM->Bbusystate) {safe_sleep(1);} SHM->Bbusystate = 1; bcache[i].brdattr = bcache[i].brdattr | BRD_NOTRAN; strncpy(bcache[i].title + 5, "◎", 2); SHM->Bbusystate = 0; substitute_record(BBSHOME"/.BRD", &bcache[i],sizeof(boardheader_t),i+1); } } return 0; }
int main() { char *str; int i = 0, fd = -1, msqid = -1; int sp_retv, sv_retv; srandom(time(NULL)); chdir(MY_BBS_HOME); mkdir(SP_DIR, 0770); umask(027); msqid = initAILogMSQ(); if (msqid < 0) return -1; #if !defined(DEBUG_MODE) if (fork()) return 0; setsid(); if (fork()) return 0; close(0); close(1); close(2); #endif signal(SIGHUP, sig_hup); signal(SIGTERM, sig_term); signal(SIGCHLD, sig_chld); fd = open(MY_BBS_HOME "/reclog/AId.lock", O_CREAT | O_RDONLY, 0660); if (flock(fd, LOCK_EX | LOCK_NB) < 0) return -1; #ifdef DEBUG_MODE printf("msq started...\n"); #endif while (1) { if(i % 128 == 0) { sv_retv = load_server(); sp_retv = load_special(); if(fork() == 0) { close(fd); update_special_html(); if(sp_retv == 1) return send_special(); else return MAX_SERVER_NUM; } } while ((str = rcvlog(msqid, 1))) { strsncpy(queue[qlen++], str, 512); #ifdef DEBUG_MODE printf("recved@%ld |%s|\n", time(NULL), str); if(qlen < 1) #else if(qlen < 16) #endif continue; if(num_server == 0) { if(qlen > MAX_QLEN - 1) qlen--;//drop msg break; } if(fork() == 0) { close(fd); return require_ai(i%num_server); } qlen=0; break; } i++; sleep(5); } }