/* builtin_agent - detached thread periodically when pending jobs can start */ extern void *builtin_agent(void *args) { time_t now; double wait_time; static time_t last_sched_time = 0; /* Read config, nodes and partitions; Write jobs */ slurmctld_lock_t all_locks = { READ_LOCK, WRITE_LOCK, READ_LOCK, READ_LOCK, READ_LOCK }; _load_config(); last_sched_time = time(NULL); while (!stop_builtin) { _my_sleep(builtin_interval); if (stop_builtin) break; if (config_flag) { config_flag = false; _load_config(); } now = time(NULL); wait_time = difftime(now, last_sched_time); if ((wait_time < builtin_interval)) continue; lock_slurmctld(all_locks); _compute_start_times(); last_sched_time = time(NULL); (void) bb_g_job_try_stage_in(); unlock_slurmctld(all_locks); } return NULL; }
/* backfill_agent - detached thread periodically attempts to backfill jobs */ extern void *backfill_agent(void *args) { time_t now; double wait_time; static time_t last_backfill_time = 0; /* Read config and partitions; Write jobs and nodes */ slurmctld_lock_t all_locks = { READ_LOCK, WRITE_LOCK, WRITE_LOCK, READ_LOCK }; _load_config(); last_backfill_time = time(NULL); while (!stop_backfill) { _my_sleep(backfill_interval); if (stop_backfill) break; if (config_flag) { config_flag = false; _load_config(); } now = time(NULL); wait_time = difftime(now, last_backfill_time); if ((wait_time < backfill_interval) || _job_is_completing() || _many_pending_rpcs() || !avail_front_end(NULL) || !_more_work(last_backfill_time)) continue; lock_slurmctld(all_locks); while (_attempt_backfill()) ; last_backfill_time = time(NULL); unlock_slurmctld(all_locks); } return NULL; }
int main(int argc, char *argv[]) { int ret = OK; //daemonize(); _signal_process(); if (_create_pid_file() == ERROR) { LOG_ERR("Create pid file error!\n"); ret = ERROR; goto exit; } if (_load_config() == ERROR) { LOG_ERR("load config error!\n"); ret = ERROR; goto exit; } _main_loop(); exit: /* Destroy pid file */ unlink(PID_FILE_PATH); return ret; }
/* * Note configuration may have changed. Handle changes in BurstBufferParameters. * * Returns a SLURM errno. */ extern int bb_p_reconfig(void) { pthread_mutex_lock(&bb_mutex); if (debug_flag) info("%s: %s", __func__, plugin_type); _load_config(); pthread_mutex_unlock(&bb_mutex); return SLURM_SUCCESS; }
/* backfill_agent - detached thread periodically attempts to backfill jobs */ extern void *backfill_agent(void *args) { struct timeval tv1, tv2; char tv_str[20]; time_t now; double wait_time; static time_t last_backfill_time = 0; /* Read config and partitions; Write jobs and nodes */ slurmctld_lock_t all_locks = { READ_LOCK, WRITE_LOCK, WRITE_LOCK, READ_LOCK }; _load_config(); last_backfill_time = time(NULL); while (!stop_backfill) { _my_sleep(backfill_interval); if (stop_backfill) break; if (config_flag) { config_flag = false; _load_config(); } now = time(NULL); wait_time = difftime(now, last_backfill_time); if ((wait_time < backfill_interval) || _job_is_completing() || _many_pending_rpcs() || !avail_front_end() || !_more_work(last_backfill_time)) continue; gettimeofday(&tv1, NULL); lock_slurmctld(all_locks); while (_attempt_backfill()) ; last_backfill_time = time(NULL); unlock_slurmctld(all_locks); gettimeofday(&tv2, NULL); _diff_tv_str(&tv1, &tv2, tv_str, 20); if (debug_flags & DEBUG_FLAG_BACKFILL) info("backfill: completed, %s", tv_str); } return NULL; }
/* backfill_agent - detached thread periodically attempts to backfill jobs */ extern void *backfill_agent(void *args) { time_t now; double wait_time; static time_t last_backfill_time = 0; /* Read config and partitions; Write jobs and nodes */ slurmctld_lock_t all_locks = { READ_LOCK, WRITE_LOCK, WRITE_LOCK, READ_LOCK }; #if HAVE_SYS_PRCTL_H if (prctl(PR_SET_NAME, "slurmctld_bckfl", NULL, NULL, NULL) < 0) { error("%s: cannot set my name to %s %m", __func__, "slurm_backfill"); } #endif _load_config(); last_backfill_time = time(NULL); while (!stop_backfill) { _my_sleep(backfill_interval * 1000000); if (stop_backfill) break; if (config_flag) { config_flag = false; _load_config(); } now = time(NULL); wait_time = difftime(now, last_backfill_time); if ((wait_time < backfill_interval) || _job_is_completing() || _many_pending_rpcs() || !avail_front_end(NULL) || !_more_work(last_backfill_time)) continue; lock_slurmctld(all_locks); (void) _attempt_backfill(); last_backfill_time = time(NULL); unlock_slurmctld(all_locks); } return NULL; }
/* Main Entry Point for this Daemon */ extern int main (int argc, char *argv[]) { sigset_t signal_set; GMainLoop *main_loop = NULL; GError *gerror = NULL; GThread *sig_thread = NULL; GOptionContext *context = NULL; gpointer trc = NULL; uid_t real_user_id = 0; uid_t effective_user_id = 0; gint rc = 0; struct passwd *userinfo = NULL; /* initialize threading and mainloop */ g_type_init(); main_loop = g_main_loop_new (NULL, FALSE); /* handle command line arguments */ if ((rc = _handle_command_line( argc, argv, &context)) != EXIT_SUCCESS) { g_main_loop_unref (main_loop); exit (rc); } /* remember real and effective userid to restore them on shutdown */ real_user_id = getuid (); if (gd_pch_effective_userid != NULL) { userinfo = getpwnam(gd_pch_effective_userid); effective_user_id = userinfo->pw_uid; } else { effective_user_id = geteuid(); userinfo = getpwuid(effective_user_id); gd_pch_effective_userid = userinfo->pw_name; } g_message("%s-%s is in startup mode as user(%s)", PACKAGE_NAME, PACKAGE_VERSION, gd_pch_effective_userid); /* daemonize */ if (!i_debug) { switch (_daemonize(gd_pch_pid_filename)) { case EXIT_SUCCESS: /* grandchild */ break; case EXIT_ERROR: /* any error */ exit (EXIT_FAILURE); break; default: /* parent or child pids */ exit (EXIT_SUCCESS); break; } } else { g_message("Skipping daemonizing process"); } /* become the requested user */ seteuid (effective_user_id); if (!i_debug) { /* block all signals */ sigfillset (&signal_set); pthread_sigmask (SIG_BLOCK, &signal_set, NULL); /* create the signal handling thread */ sig_thread = g_thread_create ((GThreadFunc)_thread_handle_signals, main_loop, TRUE, &gerror); if (gerror != NULL) { g_message("Create signal thread failed: %s", gerror->message); g_error_free(gerror); g_option_context_free(context); g_main_loop_unref (main_loop); exit (EXIT_FAILURE); } } _load_config(); if (!phonefsod_dbus_setup()) { g_option_context_free(context); g_main_loop_unref(main_loop); exit(EXIT_FAILURE); } //notify = inotify_init(); //inotify_add_watch(notify, PHONEFSOD_CONFIG, IN_MODIFY); /* Start glib main loop and run list_resources() */ g_debug("entering glib main loop"); g_timeout_add_seconds(1, fso_startup, NULL); g_main_loop_run(main_loop); phonefsod_dbus_shutdown(); /* Cleanup and exit */ if (!i_debug) { trc = g_thread_join(sig_thread); g_message("Signal thread was ended by a %s signal.", g_strsignal(GPOINTER_TO_INT(trc)) ); pthread_sigmask (SIG_UNBLOCK, &signal_set, NULL); g_option_context_free (context); } g_main_loop_unref (main_loop); // if (incoming_calls) // free(incoming_calls); // if (outgoing_calls) // free(outgoing_calls); if (sim_pin) free(sim_pin); if (pdp_apn) free(pdp_apn); if (pdp_user) free(pdp_user); if (pdp_password) free(pdp_password); /* become the privledged user again */ seteuid (real_user_id); /* Remove the PID File to show we are inactive */ if (!i_debug) { if (g_unlink(gd_pch_pid_filename) != 0) { g_warning("Main Error: cannot unlink/remove pidfile %s: %s", gd_pch_pid_filename, strerror(errno)); } } /* write shutdown messages */ g_message("%s-%s clean shutdown", PACKAGE_NAME, PACKAGE_VERSION); exit (EXIT_SUCCESS); }
static void _reload_config() { g_debug("reloading configuration"); _load_config(); }
nlp::Plsa::Plsa(std::string &conf_path) { _load_config(conf_path); _init_model(); }