17 Commits

Author SHA1 Message Date
xuu
cd1f1d7b5f fix: remove non-errors
All checks were successful
Go Bump / bump (push) Successful in 47s
Go Test / test (push) Successful in 59s
Deploy / deploy (push) Successful in 1m42s
2023-10-07 18:33:00 -06:00
xuu
a3ee0b7900 fix: return on errors
All checks were successful
Go Bump / bump (push) Successful in 46s
Go Test / test (push) Successful in 52s
Deploy / deploy (push) Successful in 1m42s
2023-10-07 18:11:35 -06:00
xuu
114c7101d6 fix: add debug levels
All checks were successful
Go Bump / bump (push) Successful in 43s
Go Test / test (push) Successful in 49s
Deploy / deploy (push) Successful in 1m42s
2023-10-07 17:57:09 -06:00
xuu
41476d04a2 fix: null pointer when unable to startu peerfinder
All checks were successful
Go Bump / bump (push) Successful in 30s
Go Test / test (push) Successful in 43s
Deploy / deploy (push) Successful in 1m25s
2023-10-02 11:26:14 -06:00
xuu
a5780449fc fix: error
All checks were successful
Go Bump / bump (push) Successful in 46s
Go Test / test (push) Successful in 1m1s
Deploy / deploy (push) Successful in 2m8s
2023-10-01 17:18:28 -06:00
xuu
4784c1c380 fix: error
All checks were successful
Go Bump / bump (push) Successful in 34s
Go Test / test (push) Successful in 46s
Deploy / deploy (push) Successful in 1m44s
2023-10-01 17:06:24 -06:00
xuu
6bb1d524b9 fix: error
All checks were successful
Go Bump / bump (push) Successful in 43s
Go Test / test (push) Successful in 56s
2023-10-01 16:56:28 -06:00
xuu
bcadac0f07 build: fix deploy
All checks were successful
Go Bump / bump (push) Successful in 31s
Go Test / test (push) Successful in 48s
2023-09-30 21:02:59 -06:00
xuu
1a2087f2ee build: fix deploy
Some checks failed
Go Bump / bump (push) Failing after 31s
Go Test / test (push) Successful in 48s
2023-09-30 21:02:21 -06:00
xuu
f2069de1ec build: fix deploy
Some checks failed
Go Bump / bump (push) Failing after 37s
Go Test / test (push) Successful in 49s
2023-09-30 21:01:23 -06:00
xuu
cdc7d62440 fix: bump version
All checks were successful
Go Bump / bump (push) Successful in 42s
Go Test / test (push) Successful in 51s
2023-09-30 20:56:24 -06:00
xuu
5180a93ee6 build: test workflow dispatch
Some checks failed
Go Bump / bump (push) Failing after 32s
Go Test / test (push) Successful in 48s
2023-09-30 20:19:33 -06:00
xuu
864a130df4 build: test workflow dispatch
All checks were successful
Go Bump / bump (push) Successful in 36s
Go Test / test (push) Successful in 48s
2023-09-30 20:10:30 -06:00
xuu
27607eb867 build: test workflow dispatch
All checks were successful
Go Bump / bump (push) Successful in 44s
Go Test / test (push) Successful in 1m0s
2023-09-30 20:05:56 -06:00
xuu
aa0782a800 build: test workflow dispatch
Some checks failed
Go Bump / bump (push) Failing after 38s
Go Test / test (push) Successful in 51s
2023-09-30 20:03:37 -06:00
xuu
8c879b31c2 build: test workflow dispatch
Some checks failed
Go Bump / bump (push) Failing after 39s
Go Test / test (push) Successful in 47s
2023-09-30 19:58:47 -06:00
xuu
f5ed427dd2 build: test workflow dispatch
All checks were successful
Go Test / test (push) Successful in 46s
2023-09-30 19:57:17 -06:00
8 changed files with 76 additions and 33 deletions

View File

@@ -5,7 +5,7 @@ After=syslog.target network.target
[Service] [Service]
Type=simple Type=simple
ExecStart=/usr/local/bin/ev ExecStart=/usr/local/bin/ev
User=www-data
Restart=always Restart=always
RestartSec=30 RestartSec=30

View File

@@ -10,12 +10,12 @@
owner: root owner: root
group: root group: root
- name: Copy build to remote # - name: Copy build to remote
ansible.builtin.copy: # ansible.builtin.copy:
src: ev.service # src: ev.service
dest: /etc/systemd/system/ev.service # dest: /etc/systemd/system/ev.service
owner: root # owner: root
group: root # group: root
- name: Restart service - name: Restart service
systemd: systemd:

View File

@@ -0,0 +1,25 @@
name: Go Bump
on:
push:
branches: [ "main" ]
jobs:
bump:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21.1
- run: go install github.com/psanetra/git-semver/cli@master
- run: git tag v$(cli next --stable=false) && git push --tags || echo no change
- run: echo "🍏 This job's status is ${{ job.status }}."

View File

@@ -1,28 +1,30 @@
name: Go Bump name: Go Bump
on: on:
# workflow_dispatch: workflow_dispatch:
# inputs: inputs:
# stable: NAME:
# description: 'Stable Release' description: "A random input name for the workflow"
# required: false type: string
# type: boolean SOME_VALUE:
# prerelease: description: "Some other input to pass"
# description: 'Pre Release' type: string
# required: false
# type: boolean # push:
push: # branches: [ "main" ]
branches: [ "main" ] # pull_request:
pull_request: # branches: [ "main" ]
branches: [ "main" ]
jobs: jobs:
bump: bump:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true
- run: echo stable=${{ inputs.stable }} pre=${{ inputs.prerelease }} - run: echo stable=${{ inputs.STABLE }} pre=${{ inputs.BETA }}
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v3 uses: actions/setup-go@v3

View File

@@ -1,8 +1,8 @@
name: Deploy name: Deploy
on: on:
# push: push:
# branches: [ "main" ] branches: [ "main" ]
release: release:
types: [ published ] types: [ published ]
@@ -11,6 +11,9 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with:
fetch-depth: 0
fetch-tags: true
- run: apt-get update && apt-get -y install ansible - run: apt-get update && apt-get -y install ansible

View File

@@ -179,7 +179,7 @@ func (s *service) getPending(w http.ResponseWriter, r *http.Request, peerID stri
return nil return nil
}) })
if err != nil { if err != nil {
span.RecordError(err) span.AddEvent(err.Error())
w.WriteHeader(http.StatusNotFound) w.WriteHeader(http.StatusNotFound)
return return
} }
@@ -204,8 +204,9 @@ func (s *service) getPending(w http.ResponseWriter, r *http.Request, peerID stri
peerResults.SetStreamID(aggPeer(peerID)) peerResults.SetStreamID(aggPeer(peerID))
err = s.es.Load(ctx, peerResults) err = s.es.Load(ctx, peerResults)
if err != nil && !errors.Is(err, ev.ErrNotFound) { if err != nil && !errors.Is(err, ev.ErrNotFound) {
span.RecordError(fmt.Errorf("peer not found: %w", err)) span.AddEvent("peer not found")
w.WriteHeader(http.StatusNotFound) w.WriteHeader(http.StatusNotFound)
return
} }
var req *Request var req *Request
@@ -221,8 +222,9 @@ func (s *service) getPending(w http.ResponseWriter, r *http.Request, peerID stri
} }
} }
if req == nil { if req == nil {
span.RecordError(fmt.Errorf("request not found")) span.AddEvent("request not found")
w.WriteHeader(http.StatusNoContent) w.WriteHeader(http.StatusNoContent)
return
} }
negotiator := contentnegotiation.NewNegotiator("application/json", "text/environment", "text/plain", "text/html") negotiator := contentnegotiation.NewNegotiator("application/json", "text/environment", "text/plain", "text/html")
@@ -304,7 +306,7 @@ func (s *service) getResults(w http.ResponseWriter, r *http.Request) {
sort.Sort(sort.Reverse(requests)) sort.Sort(sort.Reverse(requests))
args := requestArgs(r) args := requestArgs(r)
args.Requests = requests[:maxResults] args.Requests = requests[:min(maxResults, len(requests))]
s.state.Use(ctx, func(ctx context.Context, state *state) error { s.state.Use(ctx, func(ctx context.Context, state *state) error {
args.CountPeers = len(state.peers) args.CountPeers = len(state.peers)
@@ -451,6 +453,7 @@ func (s *service) postResult(w http.ResponseWriter, r *http.Request, reqID strin
if err != nil { if err != nil {
span.RecordError(fmt.Errorf("peer not found: %w", err)) span.RecordError(fmt.Errorf("peer not found: %w", err))
w.WriteHeader(http.StatusNotFound) w.WriteHeader(http.StatusNotFound)
return
} }
if peerResults.Has(reqID) { if peerResults.Has(reqID) {

View File

@@ -91,17 +91,17 @@ func (s *service) Run(ctx context.Context) (err error) {
subRes, e := s.es.EventStream().Subscribe(ctx, queueResults, 0) subRes, e := s.es.EventStream().Subscribe(ctx, queueResults, 0)
errs = multierr.Append(errs, e) errs = multierr.Append(errs, e)
if errs != nil {
return errs
}
defer func() { defer func() {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel() defer cancel()
err = multierr.Combine(subReq.Close(ctx), subRes.Close(ctx), err) err = multierr.Combine(err, subReq.Close(ctx), subRes.Close(ctx))
}() }()
if errs != nil {
return errs
}
for { for {
var events event.Events var events event.Events
select { select {

View File

@@ -4,10 +4,13 @@ import (
"context" "context"
"errors" "errors"
"log" "log"
"log/slog"
"net/http" "net/http"
"os" "os"
"os/signal" "os/signal"
"strconv"
"go.sour.is/pkg/env"
"go.sour.is/pkg/lg" "go.sour.is/pkg/lg"
"go.sour.is/pkg/service" "go.sour.is/pkg/service"
) )
@@ -27,6 +30,13 @@ func main() {
} }
} }
func run(ctx context.Context) error { func run(ctx context.Context) error {
// TODO: make this configurable.
level := slog.LevelError
if ok, _ := strconv.ParseBool(env.Default("LOG_DEBUG", "FALSE")); ok {
level = slog.LevelDebug
}
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: level})))
svc := &service.Harness{} svc := &service.Harness{}
ctx, stop := lg.Init(ctx, appName) ctx, stop := lg.Init(ctx, appName)
svc.OnStop(stop) svc.OnStop(stop)