eval ${command} -t
}
-extra_commands="reload configtest"
+reopenlog_cmd()
+{
+ export sig_reload="USR1"
+ run_rc_command reload
+}
+
+extra_commands="reload configtest reopenlog"
sig_reload="HUP"
command="$procname"
#endif
{
switch (signo) {
+ case SIGUSR1:
+ reopen_log ();
+ break;
case SIGINT:
case SIGTERM:
_exit (1);
#endif
{
switch (signo) {
+ case SIGUSR1:
+ reopen_log ();
+ break;
case SIGINT:
/* Ignore SIGINT as we should got SIGTERM after it anyway */
return;
#endif
{
switch (signo) {
+ case SIGUSR1:
+ reopen_log ();
+ break;
case SIGINT:
case SIGTERM:
_exit (1);
int
reopen_log (void)
{
-#ifdef RSPAMD_MAIN
- do_reopen_log = 0;
-#endif
close_log ();
- return open_log ();
+ if (open_log () == 0) {
+ msg_info ("log file reopened");
+ return 0;
+ }
+
+ return -1;
}
void
syslog_log_function (const gchar * log_domain, const gchar *function, GLogLevelFlags log_level, const gchar * message, gboolean forced, gpointer arg)
{
struct config_file *cfg = (struct config_file *)arg;
-#ifdef RSPAMD_MAIN
- if (do_reopen_log) {
- reopen_log ();
- }
-#endif
+
if (! rspamd_log->enabled) {
return;
}
if (! rspamd_log->enabled) {
return;
}
-#ifdef RSPAMD_MAIN
- if (do_reopen_log) {
- reopen_log ();
- }
-#endif
+
if (forced || log_level <= rspamd_log->cfg->log_level) {
/* Check repeats */
switch (signo) {
case SIGHUP:
do_restart = 1;
- do_reopen_log = 1;
break;
case SIGINT:
case SIGTERM:
case SIGCHLD:
child_dead = 1;
break;
+ case SIGUSR1:
+ do_reopen_log = 1;
+ break;
case SIGUSR2:
/* Do nothing */
break;
return TRUE;
}
+static void
+reopen_log_handler (gpointer key, gpointer value, gpointer unused)
+{
+ struct rspamd_worker *w = value;
+
+ if (kill (w->pid, SIGUSR1) == -1) {
+ msg_err ("kill failed for pid %P: %s", w->pid, strerror (errno));
+ }
+}
+
#if 0
/* XXX: remove this as it is unused now */
static gboolean
}
if (do_restart) {
do_restart = 0;
- do_reopen_log = 1;
-
+ reopen_log ();
msg_info ("rspamd " RVERSION " is restarting");
g_hash_table_foreach (rspamd->workers, kill_old_workers, NULL);
remove_all_maps ();
reread_config (rspamd);
spawn_workers (rspamd);
-
+ }
+ if (do_reopen_log) {
+ do_reopen_log = 0;
+ reopen_log ();
+ g_hash_table_foreach (rspamd->workers, reopen_log_handler, NULL);
}
if (got_alarm) {
got_alarm = 0;
struct timeval tv;
switch (signo) {
+ case SIGUSR1:
+ reopen_log ();
+ break;
case SIGINT:
case SIGTERM:
if (!wanna_die) {
unsigned int need_ssl:1;
};
-static const char *text_url = "((https?|ftp)://)?" "(\\b(?<![.\\@A-Za-z0-9-])" "(?: [A-Za-z0-9][A-Za-z0-9-]*(?:\\.[A-Za-z0-9-]+)*\\." "(?i:com|net|org|biz|edu|gov|info|name|int|mil|aero|coop|jobs|mobi|museum|pro|travel" "|cc|[rs]u|uk|ua|by|de|jp|fr|fi|no|no|ca|it|ro|cn|nl|at|nu|se" "|[a-z]{2}" "(?(1)|(?=/)))" "(?!\\w)" "|(?:\\d{1,3}\\.){3}\\d{1,3}(?(1)|(?=[/:]))" /* ip in dotted view */
+static const char *text_url = "((https?|ftp)://)?"
+ "(\\b(?<![.\\@A-Za-z0-9-])" "(?: [A-Za-z0-9][A-Za-z0-9-]*(?:\\.[A-Za-z0-9-]+)*\\."
+ "(?i:com|net|org|biz|edu|gov|info|name|int|mil|aero|coop|jobs|mobi|museum|pro|travel"
+ "|cc|[rs]u|uk|ua|by|de|jp|fr|fi|no|no|ca|it|ro|cn|nl|at|nu|se"
+ "|[a-z]{2}" "(?(1)|(?=/)))" "(?!\\w)"
+ "|(?:\\d{1,3}\\.){3}\\d{1,3}(?(1)|(?=[/:]))" /* ip in dotted view */
"|\\d{5,20}(?(1)|(?=[/:]))" /* ip in numeric view */
")" "(?::\\d{1,5})?" /* port */
"(?!\\.\\w)" /* host part ended, no more of this further on */
struct timeval tv;
switch (signo) {
+ case SIGUSR1:
+ reopen_log ();
+ break;
case SIGINT:
case SIGTERM:
if (!wanna_die) {