1
0
Fork
You've already forked goahead
0
Simple service that allows or denies server / OS restarts. A fork from https://github.com/xorpaul/goahead
Go 99.7%
Shell 0.3%
2025年10月09日 13:20:49 +02:00
examples.d reboot_completion_panic_(threshold|actions) feature implmented. 2025年07月04日 14:22:05 +02:00
go-build-release @ad60ce9667 add build_release submodule 2025年10月09日 13:20:49 +02:00
tests init version 2018年11月22日 15:55:18 +01:00
vendor update vendor 2025年10月09日 13:20:10 +02:00
.gitignore add build_release submodule 2025年10月09日 13:20:39 +02:00
.gitmodules add build_release submodule 2025年10月09日 13:20:49 +02:00
.travis.yml init version 2018年11月22日 15:55:18 +01:00
checker.go raise errors for execute statements 2021年03月18日 15:57:04 +01:00
cluster.go reboot_completion_panic_(threshold|actions) feature implmented. 2025年07月04日 14:22:05 +02:00
config.go fixed /v1/inquire/ request if the middle-ware found a reason for the client to restart 2024年09月20日 16:32:17 +02:00
config.yml init version 2018年11月22日 15:55:18 +01:00
go.mod update vendor 2025年10月09日 13:20:10 +02:00
go.sum update vendor 2025年10月09日 13:20:10 +02:00
goahead.go support yaml files besides yml and bump version to 0.0.8! 2025年08月06日 19:14:07 +02:00
goahead.spec Bumped version number to 0.0.7 2024年09月04日 16:34:43 +02:00
goahead_test.go fixes to make code work with go1.24.6 2025年08月26日 11:28:32 +02:00
helper.go Merge branch 'master' into prevent_goahead_cluster_state_cant_persist 2024年09月20日 15:47:19 +02:00
LICENSE Initial commit 2018年09月10日 16:58:11 +02:00
README.md Added go.mod; Build instructions. 2024年03月12日 13:55:38 +01:00
serve.go use os.Readfile 2024年09月20日 15:33:28 +02:00
state.go fixes to make code work with go1.24.6 2025年08月26日 11:28:32 +02:00
v1.go code cleanup using gofmt, golint, go vet 2025年08月26日 11:14:34 +02:00

goahead

Simple service that allows or denies server / OS restarts.

Client can be found here: https://github.com/xorpaul/goahead_client

Building

go mod tidy
go build

workflow

Client inquires or requests restart

Client sends request to service with URI /v1/request/restart/os with JSON payload:

{"fqdn":"foobar-server1.domain.tld","uptime":"2255h27m43s"}

goahead service checks and decides if client may restart

The fqdn from the client payload gets matched against definied cluster nodes name patterns in cluster config:

---
foobar-server:
 enabled: true
 name_pattern: "^(foobar-server-).*[[:digit:]]{2}.(domain).(tld)$"
 blacklist_name_pattern:
 - ".*-standalone-.*"
 - ".*-black-.*"
 minimum_uptime: 24h
 cluster_type: active/active
 allowed_parallel_restarts: 2
 reboot_goahead_actions:
 - /etc/goahead/goahead_hooks.d/notify_admins.sh {:%fqdn%:} {:%cluster%:}
 reboot_completion_check: /etc/goahead/reboot_completion_checks.d/check.sh {:%fqdn%:}
 reboot_completion_check_interval: 15s
 reboot_completion_check_consecutive_successes: 3
 reboot_completion_check_offset: 15m
 reboot_completion_actions:
 - /etc/goahead/goahead_hooks.d/notify_admins.sh {:%fqdn%:} {:%cluster%:}
 reboot_completion_panic_threshold: 3h

Either allows a restart with "go_ahead":true:

{"timestamp":"2018年11月22日T15:06:35.538017828Z","go_ahead":true,"unknown_host":false,"request_id":"BSporAsx","found_cluster":"foobar-server","requesting_fqdn":"foobar-server1.domain.tld","message":"","reported_uptime":"2255h27m43s"}

or denies a restart with the reason:

{"timestamp":"2018年11月22日T15:06:35.538017828Z","go_ahead":false,"unknown_host":false,"request_id":"BSporAsx","found_cluster":"foobar-server","requesting_fqdn":"foobar-server1.domain.tld","message":"Denied restart request as the current_ongoing_restarts of cluster foobar-server is larger than the allowed_parallel_restarts: 1 >= 1 Currently restarting hosts: foobar-server2.domain.tld","reported_uptime":"2255h27m43s"}

Client processes the response

If the restart request was denied via "go_ahead":false then the client terminates and will/should ask again later.

If the restart was allowed then optionally the goahead service and/or the client can trigger certian hooks. E.g. Clean removal from load-balancing/cluster or notify monitoring of upcoming restart etc.

goahead service checks for successful restart

The configured reboot_completion_check gets triggered, when the first contact from the previous client gets recieved. When the check returns with the expected return code for the configured reboot_completion_check_consecutive_successes times, then the client is considered as successfully rebooted and the amount of currently restarting cluster nodes is decremented.