#include <sys/wait.h>
#define REEXEC_FLAG "HAPROXY_SYSTEMD_REEXEC"
+#define SD_DEBUG "<7>"
+#define SD_NOTICE "<5>"
static char *pid_file = "/run/haproxy.pid";
static int wrapper_argc;
}
argv[argno] = NULL;
- printf("%s", "haproxy-systemd-wrapper: executing ");
+ fprintf(stderr, SD_DEBUG "haproxy-systemd-wrapper: executing ");
for (i = 0; argv[i]; ++i)
- printf("%s ", argv[i]);
- puts("");
+ fprintf(stderr, "%s ", argv[i]);
+ fprintf(stderr, "\n");
execv(argv[0], argv);
exit(0);
static void sigusr2_handler(int signum __attribute__((unused)))
{
setenv(REEXEC_FLAG, "1", 1);
- printf("haproxy-systemd-wrapper: re-executing\n");
+ fprintf(stderr, SD_NOTICE "haproxy-systemd-wrapper: re-executing\n");
execv(wrapper_argv[0], wrapper_argv);
}
for (i = 0; i < nb_pid; ++i) {
pid = atoi(pid_strv[i]);
if (pid > 0) {
- printf("haproxy-systemd-wrapper: SIGINT -> %d\n", pid);
+ fprintf(stderr, SD_DEBUG "haproxy-systemd-wrapper: SIGINT -> %d\n", pid);
kill(pid, SIGINT);
free(pid_strv[i]);
}
while (-1 != wait(&status) || errno == EINTR)
;
- printf("haproxy-systemd-wrapper: exit, haproxy RC=%d\n", status);
+ fprintf(stderr, SD_NOTICE "haproxy-systemd-wrapper: exit, haproxy RC=%d\n",
+ status);
return EXIT_SUCCESS;
}