Compare commits
3 Commits
multi-dock
...
wmexec
| Author | SHA1 | Date | |
|---|---|---|---|
| 20ca6a58f6 | |||
| 298345a75a | |||
| 323578e3e3 |
@@ -5,6 +5,10 @@ edition = "2021"
|
|||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "wmexec"
|
||||||
|
path = "src/bin/util/exec.rs"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "wmtest-helper-dummy"
|
name = "wmtest-helper-dummy"
|
||||||
path = "src/bin/test-helper/dummy.rs"
|
path = "src/bin/test-helper/dummy.rs"
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
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" ]
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
if [ $# -gt 0 ];then
|
|
||||||
exec "$@"
|
|
||||||
else
|
|
||||||
exec /usr/local/bin/wingmate
|
|
||||||
fi
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
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
|
|
||||||
* * * * * /etc/wingmate/crontab.d/cron4.sh
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
exec wmtest-helper-log /var/log/cron1.log "this cron runs every hour on minute 17"
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/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"
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/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 * * *"
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
exec wmtest-helper-log /var/log/cron4.log "this cron runs every minute"
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
export LOG_PATH=/var/log/one.log
|
|
||||||
exec /usr/local/bin/wmtest-helper-spawner 10
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
export LOG_PATH=/var/log/three.log
|
|
||||||
exec /usr/local/bin/wmtest-helper-spawner 13
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
export LOG_PATH=/var/log/two.log
|
|
||||||
exec /usr/local/bin/wmtest-helper-spawner 4
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
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" ]
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
17 * * * * sleep 1
|
|
||||||
*/12 * * * * sleep 1
|
|
||||||
12,17,27 * * * * sleep 1
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
you cannot run this file
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
exec sleep 1
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
exec sleep 1
|
|
||||||
40
src/bin/util/exec.rs
Normal file
40
src/bin/util/exec.rs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
use std::env;
|
||||||
|
use std::path;
|
||||||
|
|
||||||
|
struct wmexec {
|
||||||
|
log: Option<Box<dyn AsRef<path::Path>>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl wmexec {
|
||||||
|
fn new() -> wmexec {
|
||||||
|
wmexec {
|
||||||
|
log: None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn log<P: AsRef<path::Path> + 'static>(&mut self, path: P) {
|
||||||
|
self.log = Some(Box::new(path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
|
let args: Vec<String> = env::args().collect();
|
||||||
|
let mut start: usize = 0;
|
||||||
|
let mut skip_next = true;
|
||||||
|
|
||||||
|
'args: for i in 0..args.len() {
|
||||||
|
if skip_next {
|
||||||
|
skip_next = false;
|
||||||
|
continue 'args;
|
||||||
|
}
|
||||||
|
|
||||||
|
match args[i].as_str() {
|
||||||
|
"--" => {
|
||||||
|
start = i + 1;
|
||||||
|
break 'args;
|
||||||
|
},
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user