Compare commits
8 Commits
main
...
ignore-sig
| Author | SHA1 | Date | |
|---|---|---|---|
| 4cfee4c454 | |||
| 03c0c0401e | |||
| d1c78f7b71 | |||
| da71569517 | |||
| 190479d796 | |||
| 171c799a31 | |||
| 11dbe7d4f0 | |||
| d26cc87713 |
25
docker/alpine/Dockerfile
Normal file
25
docker/alpine/Dockerfile
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
FROM rust:alpine as builder
|
||||||
|
|
||||||
|
ADD . /root/wingmate
|
||||||
|
|
||||||
|
WORKDIR /root/wingmate
|
||||||
|
|
||||||
|
RUN apk add musl-dev && cargo clean && \
|
||||||
|
cargo build --release
|
||||||
|
|
||||||
|
FROM alpine
|
||||||
|
|
||||||
|
COPY --from=builder /root/wingmate/target/release/wingmate-rs /usr/local/bin/wingmate
|
||||||
|
COPY --from=builder /root/wingmate/target/release/wmtest-helper-dummy /usr/local/bin/wmtest-helper-dummy
|
||||||
|
COPY --from=builder /root/wingmate/target/release/wmtest-helper-spawner /usr/local/bin/wmtest-helper-spawner
|
||||||
|
COPY --from=builder /root/wingmate/target/release/wmtest-helper-log /usr/local/bin/wmtest-helper-log
|
||||||
|
|
||||||
|
ADD docker/alpine/etc/ /etc/
|
||||||
|
ADD docker/alpine/entry.sh /usr/local/bin/entry.sh
|
||||||
|
|
||||||
|
RUN chmod -R ugo+x /etc/wingmate && chmod +x /usr/local/bin/entry.sh && apk add tzdata && \
|
||||||
|
ln -sv /usr/share/zoneinfo/Australia/Sydney /etc/localtime
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/usr/local/bin/entry.sh" ]
|
||||||
|
|
||||||
|
CMD [ "/usr/local/bin/wingmate" ]
|
||||||
7
docker/alpine/entry.sh
Normal file
7
docker/alpine/entry.sh
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ $# -gt 0 ];then
|
||||||
|
exec "$@"
|
||||||
|
else
|
||||||
|
exec /usr/local/bin/wingmate
|
||||||
|
fi
|
||||||
3
docker/alpine/etc/wingmate/crontab
Normal file
3
docker/alpine/etc/wingmate/crontab
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
17 * * * * /etc/wingmate/crontab.d/cron1.sh
|
||||||
|
*/5 * * * * /etc/wingmate/crontab.d/cron2.sh
|
||||||
|
21,41 3,6,14,17,20,22 * * * /etc/wingmate/crontab.d/cron3.sh
|
||||||
3
docker/alpine/etc/wingmate/crontab.d/cron1.sh
Normal file
3
docker/alpine/etc/wingmate/crontab.d/cron1.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
exec wmtest-helper-log /var/log/cron1.log "this cron runs every hour on minute 17"
|
||||||
3
docker/alpine/etc/wingmate/crontab.d/cron2.sh
Normal file
3
docker/alpine/etc/wingmate/crontab.d/cron2.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
exec wmtest-helper-log /var/log/cron2.log "this cron runs every hour on minute 5,10,15,20,25,30,35,40,45,50,55"
|
||||||
3
docker/alpine/etc/wingmate/crontab.d/cron3.sh
Normal file
3
docker/alpine/etc/wingmate/crontab.d/cron3.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
exec wmtest-helper-log /var/log/cron3.log "this cron runs based on this specification: 21,41 3,6,14,17,20,22 * * *"
|
||||||
4
docker/alpine/etc/wingmate/services/one
Normal file
4
docker/alpine/etc/wingmate/services/one
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
export LOG_PATH=/var/log/one.log
|
||||||
|
exec /usr/local/bin/wmtest-helper-spawner 10
|
||||||
4
docker/alpine/etc/wingmate/services/three.sh
Normal file
4
docker/alpine/etc/wingmate/services/three.sh
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
export LOG_PATH=/var/log/three.log
|
||||||
|
exec /usr/local/bin/wmtest-helper-spawner 13
|
||||||
4
docker/alpine/etc/wingmate/services/two.sh
Normal file
4
docker/alpine/etc/wingmate/services/two.sh
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
export LOG_PATH=/var/log/two.log
|
||||||
|
exec /usr/local/bin/wmtest-helper-spawner 4
|
||||||
9
docker/bookworm/Dockerfile
Normal file
9
docker/bookworm/Dockerfile
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
FROM ubuntu:22.04
|
||||||
|
|
||||||
|
ADD target/debug/init /usr/local/bin/init
|
||||||
|
ADD docker/etc/ /etc/
|
||||||
|
|
||||||
|
RUN chmod ugo+x /etc/wingmate/services/one && chmod ugo+x /etc/wingmate/services/two.sh && \
|
||||||
|
chmod ugo-x /etc/wingmate/services/three.sh
|
||||||
|
|
||||||
|
CMD [ "/usr/local/bin/init" ]
|
||||||
3
docker/bookworm/etc/wingmate/crontab
Normal file
3
docker/bookworm/etc/wingmate/crontab
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
17 * * * * sleep 1
|
||||||
|
*/12 * * * * sleep 1
|
||||||
|
12,17,27 * * * * sleep 1
|
||||||
1
docker/bookworm/etc/wingmate/services/one
Normal file
1
docker/bookworm/etc/wingmate/services/one
Normal file
@ -0,0 +1 @@
|
|||||||
|
you cannot run this file
|
||||||
3
docker/bookworm/etc/wingmate/services/three.sh
Normal file
3
docker/bookworm/etc/wingmate/services/three.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
exec sleep 1
|
||||||
3
docker/bookworm/etc/wingmate/services/two.sh
Normal file
3
docker/bookworm/etc/wingmate/services/two.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
exec sleep 1
|
||||||
@ -8,14 +8,21 @@ use std::fs::OpenOptions;
|
|||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::env;
|
use std::env;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
use nix::sys::signal;
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
let args: Vec<String> = env::args().collect();
|
let args: Vec<String> = env::args().collect();
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
signal::signal(signal::Signal::SIGCHLD, signal::SigHandler::SigIgn)
|
||||||
|
}.unwrap();
|
||||||
|
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
|
|
||||||
let log_path = env::var("LOG_PATH")?;
|
let log_path = env::var("LOG_PATH")?;
|
||||||
let file = OpenOptions::new().append(true).create(true).open(log_path)?;
|
let file = OpenOptions::new().append(true).create(true).open(log_path)?;
|
||||||
WriteLogger::new(LevelFilter::Debug, Config::default(), file);
|
WriteLogger::init(LevelFilter::Debug, Config::default(), file)?;
|
||||||
|
|
||||||
if args.len() > 1 {
|
if args.len() > 1 {
|
||||||
let x: u64 = args[1].parse()?;
|
let x: u64 = args[1].parse()?;
|
||||||
loop {
|
loop {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user