static gboolean afprogram_dd_init(LogPipe *s) { AFProgramDestDriver *self = (AFProgramDestDriver *) s; GlobalConfig *cfg = log_pipe_get_config(s); if (!log_dest_driver_init_method(s)) return FALSE; log_writer_options_init(&self->writer_options, cfg, 0); const gboolean restore_successful = afprogram_dd_restore_reload_store_item(self, cfg); if (!self->writer) self->writer = log_writer_new(LW_FORMAT_FILE, s->cfg); log_writer_set_options(self->writer, s, &self->writer_options, STATS_LEVEL0, SCS_PROGRAM, self->super.super.id, self->process_info.cmdline->str); log_writer_set_queue(self->writer, log_dest_driver_acquire_queue(&self->super, afprogram_dd_format_queue_persist_name(self))); if (!log_pipe_init((LogPipe *) self->writer)) { log_pipe_unref((LogPipe *) self->writer); return FALSE; } log_pipe_append(&self->super.super.super, (LogPipe *) self->writer); return restore_successful ? TRUE : afprogram_dd_reopen(self); }
static gboolean afprogram_dd_init(LogPipe *s) { AFProgramDestDriver *self = (AFProgramDestDriver *) s; GlobalConfig *cfg = log_pipe_get_config(s); if (!log_dest_driver_init_method(s)) return FALSE; log_writer_options_init(&self->writer_options, cfg, 0); if (!self->writer) self->writer = log_writer_new(LW_FORMAT_FILE); log_writer_set_options(self->writer, s, &self->writer_options, STATS_LEVEL0, SCS_PROGRAM, self->super.super.id, self->cmdline->str); log_writer_set_queue(self->writer, log_dest_driver_acquire_queue(&self->super, afprogram_dd_format_persist_name(self))); log_pipe_init((LogPipe *) self->writer, NULL); log_pipe_append(&self->super.super.super, (LogPipe *) self->writer); return afprogram_dd_reopen(self); }
static void afprogram_dd_notify(LogPipe *s, LogPipe *sender, gint notify_code, gpointer user_data) { AFProgramDestDriver *self = (AFProgramDestDriver *) s; switch (notify_code) { case NC_CLOSE: case NC_WRITE_ERROR: afprogram_dd_reopen(self); break; } }
static void afprogram_dd_exit(pid_t pid, int status, gpointer s) { AFProgramDestDriver *self = (AFProgramDestDriver *) s; /* Note: self->process_info.pid being -1 means that deinit was called, thus we don't * need to restart the command. self->process_info.pid might change due to EPIPE * handling restarting the command before this handler is run. */ if (self->process_info.pid != -1 && self->process_info.pid == pid) { msg_verbose("Child program exited, restarting", evt_tag_str("cmdline", self->process_info.cmdline->str), evt_tag_int("status", status)); self->process_info.pid = -1; afprogram_dd_reopen(self); } }