/***
This file is part of systemd.
Copyright 2011 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <unistd.h>
#include "sd-daemon.h"
#include "sd-messages.h"
#include "formats-util.h"
#include "journal-authenticate.h"
#include "journald-kmsg.h"
#include "journald-server.h"
#include "journald-syslog.h"
#include "sigbus.h"
int r;
if (argc > 1) {
log_error("This program does not take arguments.");
return EXIT_FAILURE;
}
log_open();
umask(0022);
r = server_init(&server);
if (r < 0)
goto finish;
server_vacuum(&server, false, false);
LOG_MESSAGE("Journal started"),
NULL);
for (;;) {
usec_t t = USEC_INFINITY, n;
if (r < 0)
goto finish;
if (r == SD_EVENT_FINISHED)
break;
n = now(CLOCK_REALTIME);
/* The retention time is reached, so let's vacuum! */
log_info("Retention time reached.");
server_vacuum(&server, false, false);
continue;
}
/* Calculate when to rotate the next time */
}
#ifdef HAVE_GCRYPT
if (server.system_journal) {
usec_t u;
if (n >= u)
t = 0;
else
t = MIN(t, u - n);
}
}
#endif
if (r < 0) {
log_error_errno(r, "Failed to run event loop: %m");
goto finish;
}
}
LOG_MESSAGE("Journal stopped"),
NULL);
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}