fix no config panic & wingmate.yaml doc
This commit is contained in:
parent
3c0816f5f3
commit
bcb6435b4a
@ -28,7 +28,7 @@ func main() {
|
||||
wingmate.Log().Info().Msgf("starting wingmate version %s", viper.GetString(config.WingmateVersion))
|
||||
|
||||
if cfg, err = config.Read(); err != nil {
|
||||
wingmate.Log().Error().Msgf("failed to read config %#v", err)
|
||||
wingmate.Log().Fatal().Err(err).Msg("failed to read config")
|
||||
}
|
||||
|
||||
initCfg := convert(cfg)
|
||||
|
||||
59
docker/alpine/etc/wingmate/wingmate.yaml
Normal file
59
docker/alpine/etc/wingmate/wingmate.yaml
Normal file
@ -0,0 +1,59 @@
|
||||
service:
|
||||
# one:
|
||||
# command: [ "wmstarter" ]
|
||||
# environ: [ "DUMMY_PATH=/workspace/wingmate/cmd/experiment/dummy/dummy" ]
|
||||
|
||||
spawner:
|
||||
command: [ "wmspawner" ]
|
||||
user: "1200"
|
||||
|
||||
bgtest:
|
||||
command:
|
||||
- "wmstarter"
|
||||
- "--no-wait"
|
||||
- "--"
|
||||
- "wmexec"
|
||||
- "--setsid"
|
||||
- "--"
|
||||
- "wmbg"
|
||||
- "--name"
|
||||
- "test-run"
|
||||
- "--pause"
|
||||
- "10"
|
||||
- "--log-path"
|
||||
- "/var/log/wmbg.log"
|
||||
- "--pid-file"
|
||||
- "/var/run/wmbg.pid"
|
||||
pidfile: "/var/run/wmbg.pid"
|
||||
|
||||
cron:
|
||||
cron1:
|
||||
command:
|
||||
- "wmoneshot"
|
||||
- "--"
|
||||
- "sleep"
|
||||
- "5"
|
||||
schedule: "*/5 * * * *"
|
||||
environ:
|
||||
- "WINGMATE_LOG=/var/log/cron1.log"
|
||||
- "WINGMATE_LOG_MESSAGE=cron executed in minute 5,10,15,20,25,30,35,40,45,50,55"
|
||||
cron2:
|
||||
command:
|
||||
- "wmoneshot"
|
||||
- "--"
|
||||
- "sleep"
|
||||
- "5"
|
||||
schedule: "17,42 */2 * * *"
|
||||
environ:
|
||||
- "WINGMATE_LOG=/var/log/cron2.log"
|
||||
- "WINGMATE_LOG_MESSAGE=cron scheduled using 17,42 */2 * * *"
|
||||
cron3:
|
||||
command:
|
||||
- "wmoneshot"
|
||||
- "--"
|
||||
- "sleep"
|
||||
- "5"
|
||||
schedule: "7,19,23,47 22 * * *"
|
||||
environ:
|
||||
- "WINGMATE_LOG=/var/log/cron3.log"
|
||||
- "WINGMATE_LOG_MESSAGE=cron scheduled using 7,19,23,47 22 * * *"
|
||||
@ -1,4 +1,4 @@
|
||||
FROM golang:1.22-bookworm as builder
|
||||
FROM golang:1.22-bookworm AS builder
|
||||
|
||||
ADD . /root/wingmate
|
||||
WORKDIR /root/wingmate/
|
||||
@ -13,8 +13,8 @@ RUN ln -sf /usr/share/zoneinfo/Australia/Sydney /etc/localtime && \
|
||||
apt update && apt install -y procps && \
|
||||
useradd -m -s /bin/bash user1
|
||||
COPY --from=builder /usr/local/bin/wingmate/ /usr/local/bin/
|
||||
ADD --chmod=755 docker/bookworm-newconfig/entry.sh /usr/local/bin/entry.sh
|
||||
ADD --chmod=755 docker/bookworm-newconfig/etc /etc
|
||||
ADD --chmod=755 docker/bookworm/entry.sh /usr/local/bin/entry.sh
|
||||
ADD --chmod=755 docker/bookworm/etc /etc
|
||||
|
||||
ENTRYPOINT [ "/usr/local/bin/entry.sh" ]
|
||||
CMD [ "/usr/local/bin/wingmate" ]
|
||||
8
docker/test/no-config/alpine/Dockerfile
Normal file
8
docker/test/no-config/alpine/Dockerfile
Normal file
@ -0,0 +1,8 @@
|
||||
FROM suyono/wingmate:test AS source
|
||||
|
||||
|
||||
FROM alpine:3.20
|
||||
COPY --from=source /usr/local/bin/ /usr/local/bin/
|
||||
|
||||
ENTRYPOINT [ "/usr/local/bin/entry.sh" ]
|
||||
CMD [ "/usr/local/bin/wingmate" ]
|
||||
8
docker/test/no-config/bookworm/Dockerfile
Normal file
8
docker/test/no-config/bookworm/Dockerfile
Normal file
@ -0,0 +1,8 @@
|
||||
FROM suyono/wingmate:test AS source
|
||||
|
||||
|
||||
FROM debian:bookworm
|
||||
COPY --from=source /usr/local/bin/ /usr/local/bin/
|
||||
|
||||
ENTRYPOINT [ "/usr/local/bin/entry.sh" ]
|
||||
CMD [ "/usr/local/bin/wingmate" ]
|
||||
@ -46,6 +46,10 @@ func (w *wrapper) Error() logger.Content {
|
||||
return (*eventWrapper)(w.log.Error().Time(timeTag, time.Now()))
|
||||
}
|
||||
|
||||
func (w *wrapper) Fatal() logger.Content {
|
||||
return (*eventWrapper)(w.log.Fatal().Time(timeTag, time.Now()))
|
||||
}
|
||||
|
||||
type eventWrapper zerolog.Event
|
||||
|
||||
func (w *eventWrapper) Msg(msg string) {
|
||||
@ -60,3 +64,8 @@ func (w *eventWrapper) Str(key, value string) logger.Content {
|
||||
rv := (*zerolog.Event)(w).Str(key, value)
|
||||
return (*eventWrapper)(rv)
|
||||
}
|
||||
|
||||
func (w *eventWrapper) Err(err error) logger.Content {
|
||||
rv := (*zerolog.Event)(w).Err(err)
|
||||
return (*eventWrapper)(rv)
|
||||
}
|
||||
|
||||
@ -4,12 +4,14 @@ type Content interface {
|
||||
Msg(string)
|
||||
Msgf(string, ...any)
|
||||
Str(string, string) Content
|
||||
Err(error) Content
|
||||
}
|
||||
|
||||
type Level interface {
|
||||
Info() Content
|
||||
Warn() Content
|
||||
Error() Content
|
||||
Fatal() Content
|
||||
}
|
||||
|
||||
type Log interface {
|
||||
|
||||
@ -154,11 +154,30 @@ configuration depends on the [wmpidproxy](README.md#wingmate-pid-proxy-binary).
|
||||
|
||||
`cron` is a top-level element that hosts the definition of crones to run by `wingmate` on the specified schedule.
|
||||
Cron shares almost all configuration elements with Service, except `schedule` and `pidfile`. For the following
|
||||
elements, please refer to the Service section
|
||||
elements, please refer to the [Service](#service) section
|
||||
|
||||
- [Command](#command)
|
||||
- [Environ](#environ)
|
||||
- [Working Directory](#working-directory)
|
||||
- [setsid](#setsid)
|
||||
- [User and Group](#user-and-group)
|
||||
|
||||
`pidfile` is an invalid config parameter for cron because `wingmate` cannot start cron in background mode. This
|
||||
limitation is intentionally built into `wingmate` because it doesn't make any sense to run a periodic cron process
|
||||
in background.
|
||||
|
||||
### Schedule
|
||||
|
||||
The schedule configuration field uses a format similar to the one described in the [README.md](README.md).
|
||||
|
||||
```shell
|
||||
┌───────────── minute (0–59)
|
||||
│ ┌───────────── hour (0–23)
|
||||
│ │ ┌───────────── day of the month (1–31)
|
||||
│ │ │ ┌───────────── month (1–12)
|
||||
│ │ │ │ ┌───────────── day of the week (0–6) (Sunday to Saturday)
|
||||
│ │ │ │ │
|
||||
│ │ │ │ │
|
||||
│ │ │ │ │
|
||||
* * * * *
|
||||
```
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user