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