Skip to content

Commit 0580b9c

Browse files
committed
add gemini feedback
1 parent fc64740 commit 0580b9c

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func main() {
1717
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
1818
defer cancel()
1919

20-
if err := server.Run(ctx, server.Config{Version: Version}); err != nil {
20+
if err := server.Run(ctx, server.Config{Version: Version, ExitFunc: exitFunc}); err != nil {
2121
fmt.Fprintf(os.Stderr, "model-runner: %v\n", err)
2222
exitFunc(1)
2323
}

pkg/server/server.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,17 @@ import (
3131
// Config holds server startup options.
3232
type Config struct {
3333
Version string
34+
// ExitFunc is called on fatal errors that cannot be propagated via the
35+
// callback signature (e.g. OnBackendError). Defaults to os.Exit.
36+
ExitFunc func(int)
3437
}
3538

3639
// Run starts the HTTP server and blocks until ctx is cancelled.
3740
func Run(ctx context.Context, cfg Config) error {
41+
exitFunc := cfg.ExitFunc
42+
if exitFunc == nil {
43+
exitFunc = os.Exit
44+
}
3845
log := logging.NewLogger(envconfig.LogLevel())
3946

4047
sockName := envconfig.SocketPath()
@@ -183,7 +190,7 @@ func Run(ctx context.Context, cfg Config) error {
183190
),
184191
OnBackendError: func(name string, err error) {
185192
log.Error("unable to initialize backend", "backend", name, "error", err)
186-
os.Exit(1)
193+
exitFunc(1)
187194
},
188195
DefaultBackendName: llamacpp.Name,
189196
HTTPClient: http.DefaultClient,

0 commit comments

Comments
 (0)