diff options
author | Jason Song <i@wolfogre.com> | 2023-04-04 15:32:04 +0200 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2023-04-04 15:32:04 +0200 |
commit | 220efa69c0bb9d0970a36b441b33d5b3216d8c3d (patch) | |
tree | 24eb1af7d6e6a41eb179d86f8828172f85e03332 /main.go | |
parent | Config for container network (#96) (diff) | |
download | forgejo-runner-220efa69c0bb9d0970a36b441b33d5b3216d8c3d.tar.xz forgejo-runner-220efa69c0bb9d0970a36b441b33d5b3216d8c3d.zip |
Refactor to new framework (#98)
- Adjust directory structure
```text
├── internal
│ ├── app
│ │ ├── artifactcache
│ │ ├── cmd
│ │ ├── poll
│ │ └── run
│ └── pkg
│ ├── client
│ ├── config
│ ├── envcheck
│ ├── labels
│ ├── report
│ └── ver
└── main.go
```
- New pkg `labels` to parse label
- New pkg `report` to report logs to Gitea
- Remove pkg `engine`, use `envcheck` to check if docker running.
- Rewrite `runtime` to `run`
- Rewrite `poller` to `poll`
- Simplify some code and remove what's useless.
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/98
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Jason Song <i@wolfogre.com>
Co-committed-by: Jason Song <i@wolfogre.com>
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 24 |
1 files changed, 3 insertions, 21 deletions
@@ -5,33 +5,15 @@ package main import ( "context" - "os" "os/signal" "syscall" - "gitea.com/gitea/act_runner/cmd" + "gitea.com/gitea/act_runner/internal/app/cmd" ) -func withContextFunc(ctx context.Context, f func()) context.Context { - ctx, cancel := context.WithCancel(ctx) - go func() { - c := make(chan os.Signal, 1) - signal.Notify(c, syscall.SIGINT, syscall.SIGTERM) - defer signal.Stop(c) - - select { - case <-ctx.Done(): - case <-c: - cancel() - f() - } - }() - - return ctx -} - func main() { - ctx := withContextFunc(context.Background(), func() {}) + ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + defer stop() // run the command cmd.Execute(ctx) } |