Skip to content

Commit 5163d0d

Browse files
adaam2claude
andauthored
chore: server hot reload (#1791)
## Summary Adds `air` so that the go server hot reloads on any changes to the server code. --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 365894b commit 5163d0d

File tree

5 files changed

+60
-5
lines changed

5 files changed

+60
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ junit-report.xml
1919
/client/sdk/docs
2020
/server/goa*
2121
/server/gram
22+
/server/tmp
2223
# Goa generates OpenAPI v2 specs with non-deterministic examples. Nothing consumes them.
2324
/server/gen/http/openapi.yaml
2425
/server/gen/http/openapi.json

.mise-tasks/start/server.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
#MISE dir="{{ config_root }}/server"
44
#MISE description="Start up the API server"
55

6-
GIT_SHA=$(git rev-parse HEAD)
7-
86
CONFIG_ARGS=()
97
if [ -f "../config.local.toml" ]; then
108
CONFIG_ARGS=(--config-file ../config.local.toml)
119
fi
1210

13-
go run -ldflags="-X github.com/speakeasy-api/gram/server/cmd/gram.GitSHA=${GIT_SHA} -X goa.design/clue/health.Version=${GIT_SHA}" main.go start "${CONFIG_ARGS[@]}" "$@"
11+
# Use air for hot reload - args after -- are passed to the binary
12+
air -- start "${CONFIG_ARGS[@]}" "$@"

.mise-tasks/start/worker.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
#MISE dir="{{ config_root }}/server"
33
#MISE description="Start up the Temporal worker"
44

5-
GIT_SHA=$(git rev-parse HEAD)
6-
go run -ldflags="-X github.com/speakeasy-api/gram/server/cmd/gram.GitSHA=${GIT_SHA} -X goa.design/clue/health.Version=${GIT_SHA}" main.go worker
5+
# Use air for hot reload - args after -- are passed to the binary
6+
air -- worker

mise.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ uv = "0.10.4"
2525
yq = "4.52.4"
2626
hk = "1.36.0"
2727
pkl = "0.30.2"
28+
air = "1.64.5"
2829

2930
# ℹ️ The settings below are sensible defaults for local development. When
3031
# deploying to production, you will want to configure these more carefully.

server/.air.toml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Air configuration for Gram server hot reload
2+
# https://github.com/air-verse/air
3+
4+
root = "."
5+
tmp_dir = "tmp"
6+
7+
[build]
8+
# Build command - uses mise build task
9+
cmd = "mise run -q build:server"
10+
# Binary to run after build
11+
bin = "./bin/gram"
12+
# Arguments passed to binary via command line: air -- start [args...]
13+
# Watch these extensions
14+
include_ext = ["go", "toml"]
15+
# Exclude these directories
16+
exclude_dir = ["tmp", "vendor", "testdata", ".git"]
17+
# Exclude these files
18+
exclude_file = []
19+
# Exclude regex patterns
20+
exclude_regex = ["_test\\.go$"]
21+
# Exclude unchanged files
22+
exclude_unchanged = true
23+
# Follow symlinks
24+
follow_symlink = false
25+
# Log file location
26+
log = "tmp/air.log"
27+
# Poll interval for watching (in ms)
28+
poll = false
29+
poll_interval = 500
30+
# Delay before running binary (in ms)
31+
delay = 500
32+
# Stop old binary before building new one
33+
stop_on_error = true
34+
# Send interrupt signal before killing process
35+
send_interrupt = true
36+
# Delay before sending kill signal (in ms)
37+
kill_delay = 500
38+
39+
[log]
40+
# Show log time
41+
time = false
42+
# Only show main log
43+
main_only = false
44+
45+
[color]
46+
# Colorize build output
47+
main = "magenta"
48+
watcher = "cyan"
49+
build = "yellow"
50+
runner = "green"
51+
52+
[misc]
53+
# Clean tmp directory on exit
54+
clean_on_exit = true

0 commit comments

Comments
 (0)