2022-04-06 16:52:31 +02:00
|
|
|
module server
|
|
|
|
|
|
|
|
import cli
|
2022-11-01 21:43:25 +01:00
|
|
|
import conf as vconf
|
2022-04-06 16:52:31 +02:00
|
|
|
|
2022-04-06 18:20:14 +02:00
|
|
|
struct Config {
|
|
|
|
pub:
|
2022-12-06 14:11:17 +01:00
|
|
|
log_level string = 'WARN'
|
|
|
|
pkg_dir string
|
|
|
|
data_dir string
|
|
|
|
api_key string
|
|
|
|
default_arch string
|
|
|
|
global_schedule string = '0 3'
|
|
|
|
port int = 8000
|
|
|
|
base_image string = 'archlinux:base-devel'
|
2022-12-17 17:11:19 +01:00
|
|
|
max_log_age int = -1
|
2022-04-06 18:20:14 +02:00
|
|
|
}
|
|
|
|
|
2022-04-06 17:57:05 +02:00
|
|
|
// cmd returns the cli submodule that handles starting the server
|
2022-04-06 16:52:31 +02:00
|
|
|
pub fn cmd() cli.Command {
|
|
|
|
return cli.Command{
|
|
|
|
name: 'server'
|
2022-04-06 19:51:54 +02:00
|
|
|
description: 'Start the Vieter server.'
|
2022-11-01 21:10:45 +01:00
|
|
|
execute: fn (cmd cli.Command) ! {
|
|
|
|
config_file := cmd.flags.get_string('config-file')!
|
|
|
|
conf := vconf.load<Config>(prefix: 'VIETER_', default_path: config_file)!
|
2022-04-06 16:52:31 +02:00
|
|
|
|
2022-11-01 21:10:45 +01:00
|
|
|
server(conf)!
|
2022-04-06 16:52:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|