Exemplo n.º 1
0
Arquivo: app.cpp Projeto: jj4jj/dcpots
int App::start(){
    int  iret = 0;
    bool bret = 0;
    while (true){
		app_tick_update(impl_);
        if (impl_->stoping){ //need stop
            bret = on_stop();
            if (bret){
                break;
            }
            continue;
        }
        if (impl_->restarting){//need restart
            bret = on_restart();
            if (bret){
                break;
            }
            continue;
        }
        if (impl_->reloading){//need reload
            _app_reload_env(impl_);
            iret = on_reload();
            if (iret){
                GLOG_ERR("reload error ret :%d !", iret);
            }
            impl_->reloading = false;
        }
        //running
        if (impl_->stcp) { //one tick , one us ?
            iret += dctcp_poll(impl_->stcp, impl_->maxtptick, impl_->maxtptick);
        }
        iret = on_loop();
        if (iret == 0){
            on_idle();
        }
    }
    iret = impl_->shm_pool.stop();
    if (iret){
        GLOG_ERR("shm pool stop error ret:%d", iret);
    }
    return on_exit();
}
Exemplo n.º 2
0
Arquivo: lemon.c Projeto: Ndunmo/lemon
int main(int argc, char *argv[]) {

    if(argc < 2) {
        fprintf(stderr, "Usage: %s [-a <number of attemps>|-e <onerror> '<args>'|-r <onrestart> '<args>'] <program> <args>\n", argv[0]);
        exit(1);
    }


    int i;
    command_options *commands = malloc(sizeof(*commands));

    getFlags(argc, argv, commands);

    for(i = 0; i < commands->max_attempts; i++) {
        start(commands);
        on_restart(commands);
    }

    return 0;
}