Skip to content

Commit 61ec82e

Browse files
Fix CI build path by tracking cmd/rexd entrypoint.
Narrow the gitignore binary rule to the repo-root `/rexd` artifact so `cmd/rexd/main.go` is included in source control and Actions can build `./cmd/rexd`. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 8007170 commit 61ec82e

2 files changed

Lines changed: 57 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
rexd
1+
/rexd
22
rexd_verify.txt
33
.DS_Store
44

cmd/rexd/main.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"flag"
6+
"log"
7+
"os"
8+
"os/signal"
9+
"syscall"
10+
11+
"github.com/samiralibabic/rexd/internal/config"
12+
"github.com/samiralibabic/rexd/internal/server"
13+
)
14+
15+
func main() {
16+
var cfgPath string
17+
var stdio bool
18+
var httpListen string
19+
flag.StringVar(&cfgPath, "config", "/etc/rexd/config.toml", "path to rexd config")
20+
flag.BoolVar(&stdio, "stdio", false, "run JSON-RPC on stdio")
21+
flag.StringVar(&httpListen, "http", "", "listen address for HTTP/WS transport")
22+
flag.Parse()
23+
24+
cfg, err := config.Load(cfgPath)
25+
if err != nil {
26+
log.Fatalf("load config: %v", err)
27+
}
28+
if stdio {
29+
cfg.Server.Stdio = true
30+
}
31+
if httpListen != "" {
32+
cfg.Server.HTTPListen = httpListen
33+
}
34+
35+
svc, err := server.NewService(cfg)
36+
if err != nil {
37+
log.Fatalf("create service: %v", err)
38+
}
39+
40+
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
41+
defer cancel()
42+
43+
if cfg.Server.Stdio {
44+
if err := server.RunStdio(ctx, svc, os.Stdin, os.Stdout); err != nil {
45+
log.Fatalf("stdio server failed: %v", err)
46+
}
47+
return
48+
}
49+
50+
if cfg.Server.HTTPListen == "" {
51+
log.Fatal("either --stdio or --http must be configured")
52+
}
53+
if err := server.RunHTTP(ctx, cfg, svc); err != nil {
54+
log.Fatalf("http server failed: %v", err)
55+
}
56+
}

0 commit comments

Comments
 (0)