this repo has no description

Compare changes

Choose any two refs to compare.

Changed files
+120 -79
autoposters
cmd
bsky-activity
bsky-langs
bsky-modactions
bsky-users
service
-46
plc-activity.py
···
-
#!/usr/bin/env python3
-
-
from datetime import datetime, timezone
-
import sys
-
import json
-
import redis
-
import requests
-
import time
-
-
PLC_EXPORT_URL = 'https://plc.directory/export'
-
-
cids = []
-
redis_conn = redis.Redis()
-
redis_pipe = redis_conn.pipeline()
-
-
while True:
-
plc_latest = redis_conn.get('dev.edavis.muninsky.plc_latest')
-
assert plc_latest is not None, 'manually set the `plc_latest` redis key first'
-
ts = datetime.fromisoformat(plc_latest.decode())
-
ts = ts.isoformat('T', 'milliseconds').replace('+00:00', 'Z')
-
-
qs = '?after={ts}'.format(ts=ts)
-
-
print(f'Requesting {PLC_EXPORT_URL}{qs}', end=' ')
-
resp = requests.get(PLC_EXPORT_URL + qs)
-
resp.raise_for_status()
-
-
ops = 0
-
after = datetime.now(timezone.utc)
-
for line in resp.iter_lines():
-
doc = json.loads(line)
-
after = datetime.strptime(doc['createdAt'], '%Y-%m-%dT%H:%M:%S.%fZ').replace(tzinfo=timezone.utc)
-
if doc['cid'] in cids:
-
continue
-
cids.insert(0, doc['cid'])
-
redis_pipe.incr('dev.edavis.muninsky.plc_ops')
-
ops += 1
-
-
print(f'Fetched {ops} operations')
-
sys.stdout.flush()
-
cids = cids[:25]
-
-
redis_pipe.set('dev.edavis.muninsky.plc_latest', after.isoformat())
-
redis_pipe.execute()
-
-
time.sleep(5)
···
+1 -1
autoposters/bskycharts.py
···
def main():
-
client = atproto.Client()
client.login(BSKY_HANDLE, BSKY_APP_PASSWORD)
resp = requests.get(BSKY_ACTIVITY_IMAGE_URL)
···
def main():
+
client = atproto.Client('https://pds.merklehost.xyz')
client.login(BSKY_HANDLE, BSKY_APP_PASSWORD)
resp = requests.get(BSKY_ACTIVITY_IMAGE_URL)
+1 -1
cmd/bsky-langs/main.go
···
"github.com/gorilla/websocket"
)
-
const JetstreamUrl = `ws://localhost:6008/subscribe?wantedCollections=app.bsky.feed.post`
func main() {
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
···
"github.com/gorilla/websocket"
)
+
const JetstreamUrl = `wss://jetstream1.us-west.bsky.network/subscribe?wantedCollections=app.bsky.feed.post`
func main() {
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
-4
cmd/bsky-users/main.go
···
stop()
break
}
-
queue.Enqueue(event)
-
if queue.Size() < 50 {
-
log.Printf("[startup] added event")
-
}
}
}()
···
stop()
break
}
queue.Enqueue(event)
}
}()
+3 -3
service/bsky-users.service
···
[Service]
Type=simple
-
User=eric
-
WorkingDirectory=/home/eric/bsky-tools
-
ExecStart=/home/eric/bsky-tools/bin/bsky-users
TimeoutSec=10
Restart=always
RestartSec=5
···
[Service]
Type=simple
+
User=ubuntu
+
WorkingDirectory=/home/ubuntu/bsky-tools
+
ExecStart=/home/ubuntu/bsky-tools/bin/bsky-users
TimeoutSec=10
Restart=always
RestartSec=5
+3 -3
service/bsky-langs.service
···
[Service]
Type=simple
-
User=eric
-
WorkingDirectory=/home/eric/bsky-tools
-
ExecStart=/home/eric/bsky-tools/bin/bsky-langs
TimeoutSec=15
Restart=always
RestartSec=30
···
[Service]
Type=simple
+
User=ubuntu
+
WorkingDirectory=/home/ubuntu/bsky-tools
+
ExecStart=/home/ubuntu/bsky-tools/bin/bsky-langs
TimeoutSec=15
Restart=always
RestartSec=30
+6 -6
service/bsky-activity.service
···
[Unit]
-
Description=Bsky Activity
After=network.target syslog.target
[Service]
Type=simple
-
User=eric
-
WorkingDirectory=/home/eric/bsky-tools
-
ExecStart=/home/eric/.local/bin/pipenv run ./bsky-activity.py
TimeoutSec=15
-
Restart=on-failure
-
RestartSec=1
StandardOutput=journal
[Install]
···
[Unit]
+
Description=bsky activity
After=network.target syslog.target
[Service]
Type=simple
+
User=ubuntu
+
WorkingDirectory=/home/ubuntu/bsky-tools
+
ExecStart=/home/ubuntu/bsky-tools/bin/bsky-activity
TimeoutSec=15
+
Restart=always
+
RestartSec=30
StandardOutput=journal
[Install]
+55 -8
cmd/bsky-activity/main.go
···
"os"
"os/signal"
"strings"
"syscall"
appbsky "github.com/bluesky-social/indigo/api/bsky"
jetstream "github.com/bluesky-social/jetstream/pkg/models"
···
"github.com/redis/go-redis/v9"
)
const JetstreamUrl = `wss://jetstream1.us-west.bsky.network/subscribe`
var AppBskyAllowlist = map[string]bool{
···
return false
}
-
func handler(ctx context.Context, events <-chan jetstream.Event) {
rdb := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "",
···
var eventCount int
eventLoop:
-
for event := range events {
select {
case <-ctx.Done():
break eventLoop
default:
}
if event.Kind != jetstream.EventKindCommit {
continue
}
···
if _, err := pipe.Exec(ctx); err != nil {
log.Printf("failed to exec pipe\n")
}
}
}
}
···
log.Printf("websocket closed\n")
}()
-
jetstreamEvents := make(chan jetstream.Event)
-
go handler(ctx, jetstreamEvents)
log.Printf("starting up\n")
-
var event jetstream.Event
go func() {
for {
-
event = jetstream.Event{}
err := conn.ReadJSON(&event)
if err != nil {
log.Printf("ReadJSON error: %v\n", err)
stop()
break
-
} else {
-
jetstreamEvents <- event
}
}
}()
···
"os"
"os/signal"
"strings"
+
"sync"
"syscall"
+
"time"
appbsky "github.com/bluesky-social/indigo/api/bsky"
jetstream "github.com/bluesky-social/jetstream/pkg/models"
···
"github.com/redis/go-redis/v9"
)
+
type Queue struct {
+
lk sync.Mutex
+
events []jetstream.Event
+
}
+
+
func NewQueue(capacity int) *Queue {
+
return &Queue{
+
events: make([]jetstream.Event, 0, capacity),
+
}
+
}
+
+
func (q *Queue) Enqueue(event jetstream.Event) {
+
q.lk.Lock()
+
defer q.lk.Unlock()
+
+
q.events = append(q.events, event)
+
}
+
+
func (q *Queue) Dequeue() (jetstream.Event, bool) {
+
q.lk.Lock()
+
defer q.lk.Unlock()
+
+
var event jetstream.Event
+
+
if len(q.events) == 0 {
+
return event, false
+
}
+
+
event = q.events[0]
+
q.events = q.events[1:]
+
return event, true
+
}
+
+
func (q *Queue) Size() int {
+
q.lk.Lock()
+
defer q.lk.Unlock()
+
+
return len(q.events)
+
}
+
const JetstreamUrl = `wss://jetstream1.us-west.bsky.network/subscribe`
var AppBskyAllowlist = map[string]bool{
···
return false
}
+
func handler(ctx context.Context, queue *Queue) {
rdb := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "",
···
var eventCount int
eventLoop:
+
for {
select {
case <-ctx.Done():
break eventLoop
default:
}
+
event, ok := queue.Dequeue()
+
if !ok {
+
time.Sleep(100 * time.Millisecond)
+
continue
+
}
+
if event.Kind != jetstream.EventKindCommit {
continue
}
···
if _, err := pipe.Exec(ctx); err != nil {
log.Printf("failed to exec pipe\n")
}
+
log.Printf("queue size: %d\n", queue.Size())
}
}
}
···
log.Printf("websocket closed\n")
}()
+
queue := NewQueue(100_000)
+
go handler(ctx, queue)
log.Printf("starting up\n")
go func() {
for {
+
var event jetstream.Event
err := conn.ReadJSON(&event)
if err != nil {
log.Printf("ReadJSON error: %v\n", err)
stop()
break
}
+
queue.Enqueue(event)
}
}()
+11 -3
go.mod
···
module github.com/edavis/bsky-tools
-
go 1.23.0
require (
-
github.com/bluesky-social/indigo v0.0.0-20240905024844-a4f38639767f
github.com/bluesky-social/jetstream v0.0.0-20241020000921-dcd43344c716
github.com/gorilla/websocket v1.5.1
github.com/mattn/go-sqlite3 v1.14.22
github.com/pemistahl/lingua-go v1.4.0
github.com/redis/go-redis/v9 v9.3.0
)
require (
github.com/carlmjohnson/versioninfo v0.22.5 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.1 // indirect
···
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/polydawn/refmt v0.89.1-0.20221221234430-40501e09de1f // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
-
github.com/whyrusleeping/cbor-gen v0.1.3-0.20240904181319-8dc02b38228c // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
go.opentelemetry.io/otel v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
···
module github.com/edavis/bsky-tools
+
go 1.24
+
+
toolchain go1.24.7
require (
+
github.com/bluesky-social/indigo v0.0.0-20250909204019-c5eaa30f683f
github.com/bluesky-social/jetstream v0.0.0-20241020000921-dcd43344c716
+
github.com/fxamacker/cbor/v2 v2.9.0
github.com/gorilla/websocket v1.5.1
github.com/mattn/go-sqlite3 v1.14.22
github.com/pemistahl/lingua-go v1.4.0
github.com/redis/go-redis/v9 v9.3.0
+
github.com/urfave/cli/v2 v2.26.0
)
require (
github.com/carlmjohnson/versioninfo v0.22.5 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
+
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.1 // indirect
···
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/polydawn/refmt v0.89.1-0.20221221234430-40501e09de1f // indirect
+
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
+
github.com/whyrusleeping/cbor-gen v0.2.1-0.20241030202151-b7a6831be65e // indirect
+
github.com/x448/float16 v0.8.4 // indirect
+
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
go.opentelemetry.io/otel v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
+16 -4
go.sum
···
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
-
github.com/bluesky-social/indigo v0.0.0-20240905024844-a4f38639767f h1:Q9cfCAlYWIWPsSDhg5w6qcutQ7YaJtfTjiRLP/mw+pc=
-
github.com/bluesky-social/indigo v0.0.0-20240905024844-a4f38639767f/go.mod h1:Zx9nSWgd/FxMenkJW07VKnzspxpHBdPrPmS+Fspl2I0=
github.com/bluesky-social/jetstream v0.0.0-20241020000921-dcd43344c716 h1:I8+VaZKaNIGCPGXE2/VXzJGlPFEZgiFLjnge+OWFl5w=
github.com/bluesky-social/jetstream v0.0.0-20241020000921-dcd43344c716/go.mod h1:/dE2dmFell/m4zxgIbH3fkiqZ1obzr/ETj4RpgomgMs=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
···
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
···
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
···
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
···
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0 h1:GDDkbFiaK8jsSDJfjId/PEGEShv6ugrt4kYsC5UIDaQ=
github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw=
-
github.com/whyrusleeping/cbor-gen v0.1.3-0.20240904181319-8dc02b38228c h1:UsxJNcLPfyLyVaA4iusIrsLAqJn/xh36Qgb8emqtXzk=
-
github.com/whyrusleeping/cbor-gen v0.1.3-0.20240904181319-8dc02b38228c/go.mod h1:pM99HXyEbSQHcosHc0iW7YFmwnscr+t9Te4ibko05so=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
···
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
+
github.com/bluesky-social/indigo v0.0.0-20250909204019-c5eaa30f683f h1:FugOoTzh0nCMTWGqNGsjttFWVPcwxaaGD3p/nE9V8qY=
+
github.com/bluesky-social/indigo v0.0.0-20250909204019-c5eaa30f683f/go.mod h1:n6QE1NDPFoi7PRbMUZmc2y7FibCqiVU4ePpsvhHUBR8=
github.com/bluesky-social/jetstream v0.0.0-20241020000921-dcd43344c716 h1:I8+VaZKaNIGCPGXE2/VXzJGlPFEZgiFLjnge+OWFl5w=
github.com/bluesky-social/jetstream v0.0.0-20241020000921-dcd43344c716/go.mod h1:/dE2dmFell/m4zxgIbH3fkiqZ1obzr/ETj4RpgomgMs=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
···
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
+
github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM=
+
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
···
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
+
github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM=
+
github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
···
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
+
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
···
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
+
github.com/urfave/cli/v2 v2.26.0 h1:3f3AMg3HpThFNT4I++TKOejZO8yU55t3JnnSr4S4QEI=
+
github.com/urfave/cli/v2 v2.26.0/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0 h1:GDDkbFiaK8jsSDJfjId/PEGEShv6ugrt4kYsC5UIDaQ=
github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw=
+
github.com/whyrusleeping/cbor-gen v0.2.1-0.20241030202151-b7a6831be65e h1:28X54ciEwwUxyHn9yrZfl5ojgF4CBNLWX7LR0rvBkf4=
+
github.com/whyrusleeping/cbor-gen v0.2.1-0.20241030202151-b7a6831be65e/go.mod h1:pM99HXyEbSQHcosHc0iW7YFmwnscr+t9Te4ibko05so=
+
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
+
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
+
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e h1:+SOyEddqYF09QP7vr7CgJ1eti3pY9Fn3LHO1M1r/0sI=
+
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
+24
cmd/bsky-modactions/main.go
···
"net/http"
"os"
"os/signal"
comatproto "github.com/bluesky-social/indigo/api/atproto"
"github.com/fxamacker/cbor/v2"
···
}
}()
<-ctx.Done()
stop()
slog.Info("shutting down")
return nil
}
···
"net/http"
"os"
"os/signal"
+
"time"
comatproto "github.com/bluesky-social/indigo/api/atproto"
"github.com/fxamacker/cbor/v2"
···
}
}()
+
mux := http.NewServeMux()
+
mux.HandleFunc("/config", configHandler)
+
mux.HandleFunc("/", valueHandler)
+
+
srv := &http.Server{
+
Addr: "127.0.0.1:4456",
+
Handler: mux,
+
}
+
+
go func() {
+
if err := srv.ListenAndServe(); err != nil {
+
slog.Error("error starting HTTP server", "err", err)
+
return
+
}
+
}()
+
<-ctx.Done()
stop()
slog.Info("shutting down")
+
endctx, cancel := context.WithTimeout(context.TODO(), time.Minute)
+
defer cancel()
+
+
if err := srv.Shutdown(endctx); err != nil {
+
slog.Error("error shutting down server", "err", err)
+
}
+
return nil
}