forked from vieter-v/vieter
Moved config structs to more logical location
This commit is contained in:
parent
2aa2aa143c
commit
c656e672e2
5 changed files with 23 additions and 25 deletions
|
|
@ -3,6 +3,17 @@ module server
|
|||
import cli
|
||||
import env
|
||||
|
||||
struct Config {
|
||||
pub:
|
||||
log_level string = 'WARN'
|
||||
log_file string = 'vieter.log'
|
||||
pkg_dir string
|
||||
download_dir string
|
||||
api_key string
|
||||
repo_dir string
|
||||
repos_file string
|
||||
}
|
||||
|
||||
// cmd returns the cli submodule that handles starting the server
|
||||
pub fn cmd() cli.Command {
|
||||
return cli.Command{
|
||||
|
|
@ -10,7 +21,7 @@ pub fn cmd() cli.Command {
|
|||
description: 'Start the Vieter server'
|
||||
execute: fn (cmd cli.Command) ? {
|
||||
config_file := cmd.flags.get_string('config-file') ?
|
||||
conf := env.load<env.ServerConfig>(config_file) ?
|
||||
conf := env.load<Config>(config_file) ?
|
||||
|
||||
server(conf) ?
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import web
|
|||
import os
|
||||
import log
|
||||
import repo
|
||||
import env
|
||||
import util
|
||||
|
||||
const port = 8000
|
||||
|
|
@ -12,7 +11,7 @@ const port = 8000
|
|||
struct App {
|
||||
web.Context
|
||||
pub:
|
||||
conf env.ServerConfig [required; web_global]
|
||||
conf Config [required; web_global]
|
||||
pub mut:
|
||||
repo repo.Repo [required; web_global]
|
||||
// This is used to claim the file lock on the repos file
|
||||
|
|
@ -20,7 +19,7 @@ pub mut:
|
|||
}
|
||||
|
||||
// server starts the web server & starts listening for requests
|
||||
pub fn server(conf env.ServerConfig) ? {
|
||||
pub fn server(conf Config) ? {
|
||||
// Configure logger
|
||||
log_level := log.level_from_tag(conf.log_level) or {
|
||||
util.exit_with_message(1, 'Invalid log level. The allowed values are FATAL, ERROR, WARN, INFO & DEBUG.')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue