refactor: link libvieter; remove cron code & daemon

This giant commit removes the old cron daemon & parser, replacing the
latter with a C implementation that will now be maintained in a separate
C library that gets developed independently. This commit lays the
groundwork for implementing features of Vieter in C where possible.
This commit is contained in:
Jef Roosens 2023-01-12 12:26:12 +01:00
parent bfd28d6f70
commit beb90d5756
26 changed files with 278 additions and 916 deletions

View file

@ -3,17 +3,13 @@ module server
import time
import models { BuildLog }
import os
import cron.expression { CronExpression }
import cron
const fallback_log_removal_frequency = 24 * time.hour
// log_removal_daemon removes old build logs every `log_removal_frequency`.
fn (mut app App) log_removal_daemon(schedule CronExpression) {
mut start_time := time.Time{}
fn (mut app App) log_removal_daemon(schedule &cron.Expression) {
for {
start_time = time.now()
mut too_old_timestamp := time.now().add_days(-app.conf.max_log_age)
app.linfo('Cleaning logs before $too_old_timestamp')
@ -51,12 +47,7 @@ fn (mut app App) log_removal_daemon(schedule CronExpression) {
app.linfo('Cleaned $counter logs ($failed failed)')
// Sleep until the next cycle
next_time := schedule.next_from_now() or {
app.lerror("Log removal daemon couldn't calculate next time: $err.msg(); fallback to $server.fallback_log_removal_frequency")
start_time.add(server.fallback_log_removal_frequency)
}
next_time := schedule.next_from_now()
time.sleep(next_time - time.now())
}
}

View file

@ -7,7 +7,7 @@ import repo
import util
import db
import build { BuildJobQueue }
import cron.expression
import cron
import metrics
const (
@ -43,11 +43,11 @@ pub fn server(conf Config) ! {
util.exit_with_message(1, "'any' is not allowed as the value for default_arch.")
}
global_ce := expression.parse_expression(conf.global_schedule) or {
global_ce := cron.parse_expression(conf.global_schedule) or {
util.exit_with_message(1, 'Invalid global cron expression: $err.msg()')
}
log_removal_ce := expression.parse_expression(conf.log_removal_schedule) or {
log_removal_ce := cron.parse_expression(conf.log_removal_schedule) or {
util.exit_with_message(1, 'Invalid log removal cron expression: $err.msg()')
}