diff --git a/Dockerfile b/Dockerfile index 2ba6181..58087ad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 -lsqlite3 -static' make prod && \ + LDFLAGS='-lz -lbz2 -llzma -lexpat -lzstd -llz4 -static' make prod && \ mv pvieter vieter ; \ fi @@ -31,8 +31,10 @@ RUN if [ -n "${CI_COMMIT_SHA}" ]; then \ FROM busybox:1.35.0 ENV PATH=/bin \ - VIETER_DATA_DIR=/data \ - VIETER_PKG_DIR=/data/pkgs + VIETER_REPOS_DIR=/data/repos \ + VIETER_PKG_DIR=/data/pkgs \ + VIETER_DOWNLOAD_DIR=/data/downloads \ + VIETER_REPOS_FILE=/data/repos.json COPY --from=builder /app/dumb-init /app/vieter /bin/ diff --git a/src/cron/cli.v b/src/cron/cli.v index 9536c37c..24cbe2c 100644 --- a/src/cron/cli.v +++ b/src/cron/cli.v @@ -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 diff --git a/src/cron/cron.v b/src/cron/cron.v index e356faa..e10e4dd 100644 --- a/src/cron/cron.v +++ b/src/cron/cron.v @@ -3,9 +3,6 @@ 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) ? { @@ -18,8 +15,7 @@ pub fn cron(conf Config) ? { level: log_level } - log_file := os.join_path_single(conf.data_dir, cron.log_file_name) - logger.set_full_logpath(log_file) + logger.set_full_logpath(conf.log_file) logger.log_to_console_too() ce := expression.parse_expression(conf.global_schedule) or { diff --git a/src/cron/daemon/build.v b/src/cron/daemon/build.v index bc835f1..5b2e9cc 100644 --- a/src/cron/daemon/build.v +++ b/src/cron/daemon/build.v @@ -4,11 +4,11 @@ import time import sync.stdatomic import build -const ( - build_empty = 0 - build_running = 1 - build_done = 2 -) +const build_empty = 0 + +const build_running = 1 + +const build_done = 2 // clean_finished_builds removes finished builds from the build slots & returns // them. diff --git a/src/cron/daemon/daemon.v b/src/cron/daemon/daemon.v index 35cca5f..1747494 100644 --- a/src/cron/daemon/daemon.v +++ b/src/cron/daemon/daemon.v @@ -10,12 +10,11 @@ import build import docker import db -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 -) +// 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 struct ScheduledBuild { pub: diff --git a/src/server/git.v b/src/server/git.v index 6c852b8..8bfc528 100644 --- a/src/server/git.v +++ b/src/server/git.v @@ -5,6 +5,8 @@ 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 { diff --git a/src/server/server.v b/src/server/server.v index b2a2ad2..2883942 100644 --- a/src/server/server.v +++ b/src/server/server.v @@ -20,7 +20,9 @@ pub: conf Config [required; web_global] pub mut: repo repo.RepoGroupManager [required; web_global] - db db.VieterDb + // This is used to claim the file lock on the repos file + git_mutex shared util.Dummy + db db.VieterDb } // server starts the web server & starts listening for requests