check for docker on build, limit to 60 seconds
This commit is contained in:
parent
fc80ebc936
commit
2c95fbd30d
6 changed files with 17 additions and 4 deletions
3
build
3
build
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
#!/bin/sh
|
||||
# Create all the different builds for refractr
|
||||
|
||||
version=$(cat Cargo.toml | grep -m1 version | awk -F' ' '{print $3}' | sed 's|"||g')
|
||||
|
@ -12,6 +12,7 @@ docker build -t refractr:$version --build-arg UID=$uid --build-arg GID=$gid -f p
|
|||
docker tag refractr:$version refractr:latest
|
||||
docker tag refractr:$version git.brysonsteck.xyz/brysonsteck/refractr:latest
|
||||
docker tag refractr:$version git.brysonsteck.xyz/brysonsteck/refractr:$version
|
||||
test "$1" = "push" && docker push -a git.brysonsteck.xyz/brysonsteck/refractr
|
||||
|
||||
# rust build
|
||||
cargo build
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
FROM rust:slim
|
||||
ARG UID="1000"
|
||||
ARG GID="1000"
|
||||
ENV REFRACTR_DOCKER="true"
|
||||
|
||||
WORKDIR /usr/src/refractr
|
||||
COPY . .
|
||||
|
|
|
@ -148,7 +148,7 @@ pub fn read_config(paths: Vec<PathBuf>, refractr: &Refractr) -> Result<Vec<Confi
|
|||
fn verify_config(config: Config) -> Config {
|
||||
if config.schedule.enabled {
|
||||
assert_ne!(config.schedule.interval, None);
|
||||
assert!(config.schedule.interval.unwrap() >= 15);
|
||||
assert!(config.schedule.interval.unwrap() >= 60);
|
||||
}
|
||||
|
||||
assert_ne!("", match &config.work_dir {
|
||||
|
|
|
@ -37,4 +37,5 @@
|
|||
# The "interval" field is the amount of seconds refractor will wait before
|
||||
# pulling updates from the original repository if the schedule feature is enabled.
|
||||
# This field is REQUIRED if "enabled" is set to true, otherwise OPTIONAL
|
||||
# To avoid overwhelming servers, this is set to only accept values of >=60
|
||||
#interval = 300
|
||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -5,6 +5,7 @@ mod refractr;
|
|||
use clap::Parser;
|
||||
use std::path::PathBuf;
|
||||
use std::process;
|
||||
use std::env;
|
||||
use users;
|
||||
use crate::refractr::Refractr;
|
||||
|
||||
|
@ -35,13 +36,21 @@ fn get_config_default() -> &'static str {
|
|||
fn main() -> Result<(), String> {
|
||||
let args = Args::parse();
|
||||
let refractr = Refractr {
|
||||
verbose: args.verbose,
|
||||
docker: match option_env!("REFRACTR_DOCKER") {
|
||||
Some(v) => match v {
|
||||
"true" => true,
|
||||
_ => false,
|
||||
},
|
||||
None => false
|
||||
},
|
||||
pid: process::id(),
|
||||
unix: cfg!(unix)
|
||||
unix: cfg!(unix),
|
||||
verbose: args.verbose
|
||||
};
|
||||
|
||||
common::verbose(refractr.verbose, 1, format!("Level {} verbosity enabled", refractr.verbose.to_string()));
|
||||
common::verbose(refractr.verbose, 3, format!("Process ID: {}", refractr.pid));
|
||||
common::verbose(refractr.verbose, 3, format!("Running in Docker: {}", refractr.docker));
|
||||
common::verbose(refractr.verbose, 2, format!("Checking for create flag"));
|
||||
if args.create {
|
||||
common::verbose(refractr.verbose, 3, format!("Printing sample config"));
|
||||
|
|
|
@ -16,6 +16,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
|||
use std::sync::Arc;
|
||||
|
||||
pub struct Refractr {
|
||||
pub docker: bool,
|
||||
pub verbose: u8,
|
||||
pub pid: u32,
|
||||
pub unix: bool
|
||||
|
|
Loading…
Add table
Reference in a new issue