Compare commits

...

3 Commits

Author SHA1 Message Date
Jef Roosens 404669c5a7
Updated dockerfile for new config 2022-05-03 17:22:11 +02:00
Jef Roosens fda7063f2f
remove log_file setting from cron 2022-05-03 17:18:21 +02:00
Jef Roosens e840d930e1
some code cleanup 2022-05-03 17:18:12 +02:00
7 changed files with 21 additions and 22 deletions

View File

@ -23,7 +23,7 @@ RUN if [ -n "${CI_COMMIT_SHA}" ]; then \
"https://s3.rustybever.be/vieter/commits/${CI_COMMIT_SHA}/vieter-$(echo "${TARGETPLATFORM}" | sed 's:/:-:g')" && \
chmod +x vieter ; \
else \
LDFLAGS='-lz -lbz2 -llzma -lexpat -lzstd -llz4 -static' make prod && \
LDFLAGS='-lz -lbz2 -llzma -lexpat -lzstd -llz4 -lsqlite3 -static' make prod && \
mv pvieter vieter ; \
fi
@ -31,10 +31,8 @@ RUN if [ -n "${CI_COMMIT_SHA}" ]; then \
FROM busybox:1.35.0
ENV PATH=/bin \
VIETER_REPOS_DIR=/data/repos \
VIETER_PKG_DIR=/data/pkgs \
VIETER_DOWNLOAD_DIR=/data/downloads \
VIETER_REPOS_FILE=/data/repos.json
VIETER_DATA_DIR=/data \
VIETER_PKG_DIR=/data/pkgs
COPY --from=builder /app/dumb-init /app/vieter /bin/

View File

@ -6,9 +6,9 @@ import env
struct Config {
pub:
log_level string = 'WARN'
log_file string = 'vieter.log'
api_key string
address string
data_dir string
base_image string = 'archlinux:base-devel'
max_concurrent_builds int = 1
api_update_frequency int = 15

View File

@ -3,6 +3,9 @@ module cron
import log
import cron.daemon
import cron.expression
import os
const log_file_name = 'vieter.cron.log'
// cron starts a cron daemon & starts periodically scheduling builds.
pub fn cron(conf Config) ? {
@ -15,7 +18,8 @@ pub fn cron(conf Config) ? {
level: log_level
}
logger.set_full_logpath(conf.log_file)
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 {

View File

@ -4,11 +4,11 @@ import time
import sync.stdatomic
import build
const build_empty = 0
const build_running = 1
const build_done = 2
const (
build_empty = 0
build_running = 1
build_done = 2
)
// clean_finished_builds removes finished builds from the build slots & returns
// them.

View File

@ -10,11 +10,12 @@ import build
import docker
import db
// How many seconds to wait before retrying to update API if failed
const api_update_retry_timeout = 5
// How many seconds to wait before retrying to rebuild image if failed
const rebuild_base_image_retry_timout = 30
const (
// How many seconds to wait before retrying to update API if failed
api_update_retry_timeout = 5
// How many seconds to wait before retrying to rebuild image if failed
rebuild_base_image_retry_timout = 30
)
struct ScheduledBuild {
pub:

View File

@ -5,8 +5,6 @@ import net.http
import response { new_data_response, new_response }
import db
const repos_file = 'repos.json'
// get_repos returns the current list of repos.
['/api/repos'; get]
fn (mut app App) get_repos() web.Result {

View File

@ -20,9 +20,7 @@ pub:
conf Config [required; web_global]
pub mut:
repo repo.RepoGroupManager [required; web_global]
// This is used to claim the file lock on the repos file
git_mutex shared util.Dummy
db db.VieterDb
db db.VieterDb
}
// server starts the web server & starts listening for requests