Bo-Yi Wu
1b9633ab2f
refactor(poll): use per-worker backoff counters
...
- Introduce workerState holding consecutiveEmpty and consecutiveErrors
- Plumb workerState through pollOnce, fetchTask and calculateInterval
- Drop the shared atomic.Int64 counters from Poller
With Capacity > 1, the previous shared counters inflated whenever multiple
workers each saw a single empty response, triggering an unnecessarily long
backoff. Per-worker state keeps each goroutine's backoff independent.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-04-12 11:24:33 +08:00
Bo-Yi Wu
fc4eef3e0d
fix(poll): fetch task before sleeping to avoid startup delay
...
- Reorder pollOnce to fetch first and sleep after, matching the
original rate.Limiter burst=1 behavior where the first poll
returns immediately
- Remove unused ReportInterval config field that was never shipped
2026-04-11 10:27:24 +08:00
Bo-Yi Wu
ec07b8c00b
perf: reduce runner-to-server connection load with adaptive reporting and polling
...
- Replace fixed 1s RunDaemon timer with event-driven select loop using
separate log (3s) and state (5s) tickers for periodic flush
- Add batch-size threshold (default 100 rows) to flush logs immediately
during bursty output like npm install
- Add max-latency timer (default 5s) to guarantee single log lines are
delivered within a bounded time
- Trigger immediate flush on step transitions (start/stop) and job
result for responsive frontend UX
- Skip ReportLog when no pending rows and ReportState when state is
unchanged to eliminate no-op HTTP requests
- Replace fixed-rate polling with exponential backoff and jitter to
prevent thundering herd on idle runners
- Tune HTTP client with MaxIdleConnsPerHost=10 and share a single
http.Client between Ping and Runner service clients
- Add configurable options: log_report_interval, log_report_max_latency,
log_report_batch_size, state_report_interval, fetch_interval_max
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com >
2026-04-10 22:41:38 +08:00
silverwind
658101d9cb
chore(lint): add golangci-lint v2 and fix all lint issues ( #803 )
...
## Summary
- Replace old `.golangci.yml` (v1 format) with v2 format, aligned with gitea's lint config
- Add `lint-go`, `lint-go-fix`, and `lint` Makefile targets using golangci-lint v2.10.1
- Replace `make vet` with `make lint` in CI workflow (lint includes vet)
- Fix all 35 lint issues: modernize (maps.Copy, range over int, any), perfsprint (errors.New), unparam (remove unused parameters), revive (var naming), staticcheck, forbidigo exclusion for cmd/
- Make `security-check` non-fatal (apply https://github.com/go-gitea/gitea/pull/36681 )
- Remove dead gocritic exclusion rules (commentFormatting, exitAfterDefer)
- Remove dead linter exclusions and disabled checks (singleCaseSwitch, ST1003, QF1001, QF1006, QF1008, testifylint go-require/require-error, test file exclusions for dupl/errcheck/staticcheck/unparam)
## Test plan
- [x] `golangci-lint run` passes
- [x] `go build ./...` passes
- [x] `go test ./...` passes
---------
Co-authored-by: ChristopherHX <christopher.homberger@web.de >
Co-authored-by: Christopher Homberger <christopher.homberger@web.de >
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/803
Reviewed-by: ChristopherHX <christopherhx@noreply.gitea.com >
2026-02-22 17:35:08 +00:00
garet90
8bc0275e74
feat: add once flag to daemon command ( #19 ) ( #598 )
...
Once flag polls and completes one job then exits.
I use this with Windows Sandbox (and creating users with local brew install on Mac) to create a fresh environment every time.
Co-authored-by: Garet Halliday <garet@pit.dev >
Co-authored-by: Jason Song <wolfogre@noreply.gitea.com >
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/598
Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.com >
Reviewed-by: Jason Song <wolfogre@noreply.gitea.com >
Co-authored-by: garet90 <garet90@noreply.gitea.com >
Co-committed-by: garet90 <garet90@noreply.gitea.com >
2024-11-06 17:16:08 +00:00
rowan-allspice
d1d3cad4b0
feat: allow graceful shutdowns ( #546 )
...
Add a `Shutdown(context.Context) error` method to the Poller. Calling this method will first shutdown all active polling, preventing any new jobs from spawning. It will then wait for either all jobs to finish, or for the context to be cancelled. If the context is cancelled, it will then force all jobs to end, and then exit.
Fixes https://gitea.com/gitea/act_runner/issues/107
Co-authored-by: Rowan Bohde <rowan.bohde@gmail.com >
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/546
Reviewed-by: Jason Song <i@wolfogre.com >
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com >
Co-authored-by: rowan-allspice <rowan-allspice@noreply.gitea.com >
Co-committed-by: rowan-allspice <rowan-allspice@noreply.gitea.com >
2024-05-27 07:38:55 +00:00
Jason Song
23ec12b8cf
Bump act to v0.260.0 ( #522 )
...
Related to https://gitea.com/gitea/act/issues/99 .
Also update other main dependencies.
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/522
Reviewed-by: Zettat123 <zettat123@noreply.gitea.com >
2024-03-27 03:17:04 +00:00
sillyguodong
12999b61dd
Reduce unnecessary DB queries for Actions tasks ( #219 )
...
implement: https://github.com/go-gitea/gitea/issues/24544
Changes:
- Add a global variable `tasksVersion` to store the lastest version number which returned by Gitea.
- Pass `tasksVersion` to Gitea when invoking `FetchTask`.
- If there is no task in the `FetchTask` response, store the version from the `FetchTask` response into `tasksVersion` variable.
- If there is a task in the `FetchTask` response, set `tasksVersion` to zero to focre query db in next `FetchTask` request.
Related:
- Protocol: https://gitea.com/gitea/actions-proto-def/pulls/10
- Gitea side: https://github.com/go-gitea/gitea/pull/25199
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/219
Co-authored-by: sillyguodong <gedong_1994@163.com >
Co-committed-by: sillyguodong <gedong_1994@163.com >
2023-07-25 03:25:50 +00:00
caicandong
49a2fcc138
fix endless loop ( #306 )
...
fix endless loop in poll
relate #305
Co-authored-by: CaiCandong <1290147055@qq.com >
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/306
Co-authored-by: caicandong <caicandong@noreply.gitea.com >
Co-committed-by: caicandong <caicandong@noreply.gitea.com >
2023-07-24 07:07:53 +00:00
caicandong
a1bb3b56fd
Catch the panic and print the error ( #305 )
...
refactor # 215 Catch the panic and print the error
close #215
Co-authored-by: CaiCandong <1290147055@qq.com >
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/305
Co-authored-by: caicandong <caicandong@noreply.gitea.com >
Co-committed-by: caicandong <caicandong@noreply.gitea.com >
2023-07-24 04:28:44 +00:00
Jason Song
9c6499ec08
Fix panic when response is nil ( #105 )
...
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/105
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com >
Co-authored-by: Jason Song <i@wolfogre.com >
Co-committed-by: Jason Song <i@wolfogre.com >
2023-04-06 21:51:46 +08:00
Jason Song
d139faa40c
Supports configuring fetch_timeout and fetch_interval. ( #100 )
...
Fix #99 .
Fix #94 .
Reviewed-on: https://gitea.com/gitea/act_runner/pulls/100
Reviewed-by: Zettat123 <zettat123@noreply.gitea.io >
2023-04-06 10:57:36 +08:00
Jason Song
220efa69c0
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 >
2023-04-04 21:32:04 +08:00