Example #1
0
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;
}
Example #2
0
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;
}
Example #3
0
void complete_shutdown(Server *srv)
{
    fdclose(srv->listen_fd);
    int attempts = 0;
    int rc = 0;
    
    rc = taskallsignal(SIGTERM);
    check(rc != -1, "Failed to send the TERM signal to all internal tasks.");

    log_info("Shutting down all running tasks as gracefully as possible.");
    
    // we will always be the last task, so wait until only 1 is running, us
    for(attempts = 0; tasksrunning() > 1 && attempts < 20; attempts++) {
        rc = taskallsignal(SIGTERM);
        check(rc != -1, "Failed to send the TERM signal to internal tasks on attempt: %d.", attempts);
    }

    log_info("Tasks now running (including main task): %d", tasksrunning());

    Control_port_stop();
    rc = Log_term();
    check(rc != -1, "Failed to shutdown the logging subsystem.");

    Setting_destroy();
    MIME_destroy();

    if(access((char *)srv->pid_file->data, F_OK) == 0) {
        log_info("Removing pid file %s", bdata(srv->pid_file));
        rc = unlink((const char *)srv->pid_file->data);
        check(rc != -1, "Failed to unlink pid_file: %s", bdata(srv->pid_file));
    }

    rc = Server_queue_destroy();
    check(rc == 0, "Failed cleaning up the server run queue.");

    Register_destroy();
    fdshutdown();

    taskexitall(0);
error:
    taskexitall(1);
}