27 #include <interface.h> 32 #include <libfossrepo.h> 42 int main(
int argc,
char** argv)
45 gboolean db_reset = FALSE;
46 gboolean ki_kill = FALSE;
47 gboolean ki_shut = FALSE;
48 gboolean db_init = FALSE;
49 gboolean test_die = FALSE;
50 gboolean s_daemon = FALSE;
52 GOptionContext* options;
60 if(getenv(
"FO_SYSCONFDIR") != NULL)
61 sysconfigdir = getenv(
"FO_SYSCONFDIR");
65 #if !(GLIB_MAJOR_VERSION >= 2 && GLIB_MINOR_VERSION >= 32) 68 #if !(GLIB_MAJOR_VERSION >= 2 && GLIB_MINOR_VERSION >= 36) 73 GOptionEntry entries[] =
75 {
"daemon",
'd', 0, G_OPTION_ARG_NONE, &s_daemon,
" Run scheduler as daemon" },
76 {
"database",
'i', 0, G_OPTION_ARG_NONE, &db_init,
" Initialize database connection and exit" },
77 {
"kill",
'k', 0, G_OPTION_ARG_NONE, &ki_kill,
" Forcibly kills all running schedulers" },
78 {
"shutdown",
's', 0, G_OPTION_ARG_NONE, &ki_shut,
" Gracefully shutdown of all running schedulers" },
79 {
"log",
'L', 0, G_OPTION_ARG_STRING, &logdir,
"[str] Specify location of log file" },
80 {
"port",
'p', 0, G_OPTION_ARG_INT, &port,
"[num] Set the interface port" },
81 {
"reset",
'R', 0, G_OPTION_ARG_NONE, &db_reset,
" Reset the job queue upon startup" },
82 {
"test",
't', 0, G_OPTION_ARG_NONE, &test_die,
" Close the scheduler after running tests" },
83 {
"verbose",
'v', 0, G_OPTION_ARG_INT, &
verbose,
"[num] Set the scheduler verbose level" },
84 {
"config",
'c', 0, G_OPTION_ARG_STRING, &
sysconfigdir,
"[str] Specify system configuration directory" },
91 options = g_option_context_new(
"- scheduler for FOSSology");
92 g_option_context_add_main_entries(options, entries, NULL);
93 g_option_context_parse(options, &argc, &argv, &error);
97 fprintf(stderr,
"ERROR: %s\n", error->message);
98 fprintf(stderr,
"%s", g_option_context_get_help(options, FALSE, NULL));
103 g_option_context_free(options);
111 log_new(
"stdout",
"initializing", getpid()));
115 scheduler->
logdir = logdir;
133 NOTIFY(
"*****************************************************************");
134 NOTIFY(
"*** FOSSology scheduler started ***");
135 NOTIFY(
"*** pid: %-33d ***", getpid());
136 NOTIFY(
"*** verbose: %-33d ***",
verbose);
137 NOTIFY(
"*** config: %-33s ***", sysconfigdir);
138 NOTIFY(
"*****************************************************************");
158 NOTIFY(
"*****************************************************************");
159 NOTIFY(
"*** FOSSology scheduler closed ***");
160 NOTIFY(
"*** pid: %-34d ***", scheduler->
s_pid);
161 NOTIFY(
"*****************************************************************\n");
void database_reset_queue(scheduler_t *scheduler)
Resets any jobs in the job queue that are not completed.
int closing
Set if scheduler is shutting down.
int scheduler_daemonize(scheduler_t *scheduler)
Daemonizes the scheduler.
fo_conf * sysconfig
Configuration information loaded from the configuration file.
int main(int argc, char **argv)
void interface_destroy(scheduler_t *scheduler)
Closes the server socket and thread pool that service UI connections.
void scheduler_destroy(scheduler_t *scheduler)
Free any memory associated with a scheduler_t.
void log_destroy(log_t *log)
Free memory associated with the log file.
void email_init(scheduler_t *scheduler)
Loads information about the email that will be sent for job notifications.
void database_init(scheduler_t *scheduler)
gboolean logcmdline
Was the log file set by the command line.
int kill_scheduler(int force)
Kills all other running scheduler.
void scheduler_update(scheduler_t *scheduler)
Update function called after every event.
gboolean s_daemon
Is the scheduler being run as a daemon.
log_t * log_new(gchar *log_name, gchar *pro_name, pid_t pro_pid)
Creates a new log.
void scheduler_sig_handle(int signo)
Handles any signals sent to the scheduler that are not SIGCHLD.
void scheduler_agent_config(scheduler_t *scheduler)
Loads a particular agents configuration file.
int verbose
The verbose flag for the cli.
void scheduler_foss_config(scheduler_t *scheduler)
Loads the configuration data from fossology.conf.
int fo_RepOpenFull(fo_conf *config)
Loads common information from configuration files into ram.
scheduler_t * scheduler_init(gchar *sysconfigdir, log_t *log)
Create a new scheduler object.
Event handling operations.
Header file with agent related operations.
void interface_init(scheduler_t *scheduler)
Create the interface thread and thread pool that handle UI connections.
gboolean s_pid
The pid of the scheduler process.
log_t * main_log
The main log file for the scheduler.
void scheduler_signal(scheduler_t *scheduler)
Function that handles certain signals being delivered to the scheduler.
gchar * logdir
The directory to put the log file in.
Header file for the scheduler.
int event_loop_enter(scheduler_t *scheduler, void(*update_call)(scheduler_t *), void(*signal_call)(scheduler_t *))
Enters the event loop.
gchar * process_name
The name of the scheduler process.