~comcloudway/builds.sr.ht

fc9a192d8797bbc64c400375ac736dbee52d22c8 — Drew DeVault 5 years ago 6a14d46
worker: update SSH port selection logic
2 files changed, 4 insertions(+), 4 deletions(-)

M worker/go.mod
M worker/tasks.go
M worker/go.mod => worker/go.mod +2 -0
@@ 21,3 21,5 @@ require (
	github.com/vaughan0/go-ini v0.0.0-20130923145212-a98ad7ee00ec
	golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e
)

go 1.13

M worker/tasks.go => worker/tasks.go +2 -4
@@ 32,11 32,9 @@ var (
func (ctx *JobContext) Boot(r *redis.Client) func() {
	port, err := r.Incr("builds.sr.ht.ssh-port").Result()
	if err == nil && port < 22000 {
		port = 22000
		err = r.Set("builds.sr.ht.ssh-port", port, 0).Err()
		err = r.Set("builds.sr.ht.ssh-port", 22100, 0).Err()
	} else if err == nil && port >= 23000 {
		port = 22000
		err = r.Set("builds.sr.ht.ssh-port", port, 0).Err()
		err = r.Set("builds.sr.ht.ssh-port", 22000, 0).Err()
	}
	if err != nil {
		panic(errors.Wrap(err, "assign port"))