Use only LOG_NOTICE and LOG_WARNING
These are the two priorities that go to a normal place (/var/log/messages) by default.
This commit is contained in:
parent
3a57df720e
commit
449b0918ce
12
daemon.c
12
daemon.c
@ -62,7 +62,7 @@ static void configerr(bool exit, const char *format, ...) {
|
|||||||
if (exit) {
|
if (exit) {
|
||||||
verrx(EX_DATAERR, format, ap);
|
verrx(EX_DATAERR, format, ap);
|
||||||
} else {
|
} else {
|
||||||
vsyslog(LOG_ERR, format, ap);
|
vsyslog(LOG_WARNING, format, ap);
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
@ -266,7 +266,7 @@ int main(int argc, char *argv[]) {
|
|||||||
if (daemonize) {
|
if (daemonize) {
|
||||||
error = daemon(0, 0);
|
error = daemon(0, 0);
|
||||||
if (error) {
|
if (error) {
|
||||||
syslog(LOG_ERR, "daemon: %m");
|
syslog(LOG_WARNING, "daemon: %m");
|
||||||
return EX_OSERR;
|
return EX_OSERR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -327,7 +327,7 @@ int main(int argc, char *argv[]) {
|
|||||||
&mask
|
&mask
|
||||||
);
|
);
|
||||||
if (nfds < 0 && errno != EINTR) {
|
if (nfds < 0 && errno != EINTR) {
|
||||||
syslog(LOG_ERR, "ppoll: %m");
|
syslog(LOG_WARNING, "ppoll: %m");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,7 +338,7 @@ int main(int argc, char *argv[]) {
|
|||||||
snprintf(buf, sizeof(buf), "%s", line);
|
snprintf(buf, sizeof(buf), "%s", line);
|
||||||
parseControl(buf);
|
parseControl(buf);
|
||||||
}
|
}
|
||||||
if (errno != EAGAIN) syslog(LOG_ERR, "read: %m");
|
if (errno != EAGAIN) syslog(LOG_WARNING, "read: %m");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nfds > 0) {
|
if (nfds > 0) {
|
||||||
@ -367,7 +367,7 @@ int main(int argc, char *argv[]) {
|
|||||||
while (0 < (pid = waitpid(-1, &status, WNOHANG))) {
|
while (0 < (pid = waitpid(-1, &status, WNOHANG))) {
|
||||||
serviceReap(pid, status);
|
serviceReap(pid, status);
|
||||||
}
|
}
|
||||||
if (pid < 0 && errno != ECHILD) syslog(LOG_ERR, "waitpid: %m");
|
if (pid < 0 && errno != ECHILD) syslog(LOG_WARNING, "waitpid: %m");
|
||||||
signals[SIGCHLD] = 0;
|
signals[SIGCHLD] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -397,7 +397,7 @@ int main(int argc, char *argv[]) {
|
|||||||
int status;
|
int status;
|
||||||
pid_t pid = wait(&status);
|
pid_t pid = wait(&status);
|
||||||
if (pid < 0) {
|
if (pid < 0) {
|
||||||
syslog(LOG_ERR, "wait: %m");
|
syslog(LOG_WARNING, "wait: %m");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
serviceReap(pid, status);
|
serviceReap(pid, status);
|
||||||
|
38
service.c
38
service.c
@ -114,24 +114,24 @@ err:
|
|||||||
|
|
||||||
void serviceStatus(struct Service *service) {
|
void serviceStatus(struct Service *service) {
|
||||||
if (service->state == Stop && service->intent == Stop) {
|
if (service->state == Stop && service->intent == Stop) {
|
||||||
syslog(LOG_INFO, "%s[] is stopped", service->name);
|
syslog(LOG_NOTICE, "%s[] is stopped", service->name);
|
||||||
} else if (service->state == Stop && service->intent == Start) {
|
} else if (service->state == Stop && service->intent == Start) {
|
||||||
struct timespec now, timeleft;
|
struct timespec now, timeleft;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
timespecsub(&service->restartDeadline, &now, &timeleft);
|
timespecsub(&service->restartDeadline, &now, &timeleft);
|
||||||
syslog(
|
syslog(
|
||||||
LOG_INFO, "%s[] is restarting in %lds",
|
LOG_NOTICE, "%s[] is restarting in %lds",
|
||||||
service->name, (long)timeleft.tv_sec
|
service->name, (long)timeleft.tv_sec
|
||||||
);
|
);
|
||||||
} else if (service->state == Stop && service->intent == Restart) {
|
} else if (service->state == Stop && service->intent == Restart) {
|
||||||
syslog(LOG_INFO, "%s[] is restarting", service->name);
|
syslog(LOG_NOTICE, "%s[] is restarting", service->name);
|
||||||
} else if (service->state == Start && service->intent == Start) {
|
} else if (service->state == Start && service->intent == Start) {
|
||||||
syslog(LOG_INFO, "%s[%d] is started", service->name, service->pid);
|
syslog(LOG_NOTICE, "%s[%d] is started", service->name, service->pid);
|
||||||
} else if (service->state == Start && service->intent == Stop) {
|
} else if (service->state == Start && service->intent == Stop) {
|
||||||
syslog(LOG_INFO, "%s[%d] is stopping", service->name, service->pid);
|
syslog(LOG_NOTICE, "%s[%d] is stopping", service->name, service->pid);
|
||||||
} else if (service->state == Start && service->intent == Restart) {
|
} else if (service->state == Start && service->intent == Restart) {
|
||||||
syslog(
|
syslog(
|
||||||
LOG_INFO, "%s[%d] is stopping for restart",
|
LOG_NOTICE, "%s[%d] is stopping for restart",
|
||||||
service->name, service->pid
|
service->name, service->pid
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -159,11 +159,11 @@ void serviceStart(struct Service *service) {
|
|||||||
service->intent = Start;
|
service->intent = Start;
|
||||||
service->pid = fork();
|
service->pid = fork();
|
||||||
if (service->pid < 0) {
|
if (service->pid < 0) {
|
||||||
syslog(LOG_ERR, "fork: %m");
|
syslog(LOG_WARNING, "fork: %m");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (service->pid) {
|
if (service->pid) {
|
||||||
syslog(LOG_INFO, "%s[%d] started", service->name, service->pid);
|
syslog(LOG_NOTICE, "%s[%d] started", service->name, service->pid);
|
||||||
service->state = Start;
|
service->state = Start;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -204,7 +204,7 @@ void serviceSignal(struct Service *service, int signal) {
|
|||||||
int error = kill(service->pid, signal);
|
int error = kill(service->pid, signal);
|
||||||
if (error) {
|
if (error) {
|
||||||
syslog(
|
syslog(
|
||||||
LOG_ERR, "kill(%s[%d], %s): %m",
|
LOG_WARNING, "kill(%s[%d], %s): %m",
|
||||||
service->name, service->pid, sys_signame[signal]
|
service->name, service->pid, sys_signame[signal]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -224,28 +224,28 @@ void serviceRestart(struct Service *service) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void serviceLog(struct Service *service, int pri, const char *log) {
|
static void serviceLog(struct Service *service, const char *log) {
|
||||||
syslog(pri, "%s[%d]: %s", service->name, service->pid, log);
|
syslog(LOG_NOTICE, "%s[%d]: %s", service->name, service->pid, log);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serviceRead(struct Service *service) {
|
void serviceRead(struct Service *service) {
|
||||||
const char *out;
|
const char *out;
|
||||||
while (NULL != (out = lineRead(&service->outLine, service->outPipe[0]))) {
|
while (NULL != (out = lineRead(&service->outLine, service->outPipe[0]))) {
|
||||||
serviceLog(service, LOG_INFO, out);
|
serviceLog(service, out);
|
||||||
}
|
}
|
||||||
if (errno != EAGAIN) syslog(LOG_ERR, "read: %m");
|
if (errno != EAGAIN) syslog(LOG_WARNING, "read: %m");
|
||||||
const char *err;
|
const char *err;
|
||||||
while (NULL != (err = lineRead(&service->errLine, service->errPipe[0]))) {
|
while (NULL != (err = lineRead(&service->errLine, service->errPipe[0]))) {
|
||||||
serviceLog(service, LOG_NOTICE, err);
|
serviceLog(service, err);
|
||||||
}
|
}
|
||||||
if (errno != EAGAIN) syslog(LOG_ERR, "read: %m");
|
if (errno != EAGAIN) syslog(LOG_WARNING, "read: %m");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void serviceFlush(struct Service *service) {
|
static void serviceFlush(struct Service *service) {
|
||||||
const char *out = lineFlush(&service->outLine);
|
const char *out = lineFlush(&service->outLine);
|
||||||
const char *err = lineFlush(&service->errLine);
|
const char *err = lineFlush(&service->errLine);
|
||||||
if (out) serviceLog(service, LOG_INFO, out);
|
if (out) serviceLog(service, out);
|
||||||
if (err) serviceLog(service, LOG_NOTICE, err);
|
if (err) serviceLog(service, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serviceReap(pid_t pid, int status) {
|
void serviceReap(pid_t pid, int status) {
|
||||||
@ -285,11 +285,11 @@ void serviceReap(pid_t pid, int status) {
|
|||||||
// TODO: Determine if restart interval should be reset?
|
// TODO: Determine if restart interval should be reset?
|
||||||
setDeadline(service);
|
setDeadline(service);
|
||||||
syslog(
|
syslog(
|
||||||
LOG_INFO, "%s[%d] restarting in %lds",
|
LOG_NOTICE, "%s[%d] restarting in %lds",
|
||||||
service->name, pid, (long)service->restartInterval.tv_sec
|
service->name, pid, (long)service->restartInterval.tv_sec
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
syslog(LOG_INFO, "%s[%d] stopped", service->name, pid);
|
syslog(LOG_NOTICE, "%s[%d] stopped", service->name, pid);
|
||||||
}
|
}
|
||||||
if (service->intent == Restart) {
|
if (service->intent == Restart) {
|
||||||
serviceStart(service);
|
serviceStart(service);
|
||||||
|
Loading…
Reference in New Issue
Block a user