vieter/src/cron/cron.v

34 lines
895 B
Coq
Raw Normal View History

2022-04-09 09:46:07 +02:00
module cron
import log
import cron.daemon
import cron.expression
import os
const log_file_name = 'vieter.cron.log'
2022-04-09 09:46:07 +02:00
// cron starts a cron daemon & starts periodically scheduling builds.
2022-11-01 21:10:45 +01:00
pub fn cron(conf Config) ! {
// Configure logger
log_level := log.level_from_tag(conf.log_level) or {
return error('Invalid log level. The allowed values are FATAL, ERROR, WARN, INFO & DEBUG.')
}
mut logger := log.Log{
level: log_level
}
log_file := os.join_path_single(conf.data_dir, cron.log_file_name)
logger.set_full_logpath(log_file)
logger.log_to_console_too()
ce := expression.parse_expression(conf.global_schedule) or {
return error('Error while parsing global cron expression: $err.msg()')
}
mut d := daemon.init_daemon(logger, conf.address, conf.api_key, conf.base_image, ce,
2022-11-01 21:10:45 +01:00
conf.max_concurrent_builds, conf.api_update_frequency, conf.image_rebuild_frequency)!
2022-05-01 09:14:33 +02:00
d.run()
2022-04-09 09:46:07 +02:00
}