mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-24 11:14:23 +01:00
sync
This commit is contained in:
32
cmd/opencode/opencode.go
Normal file
32
cmd/opencode/opencode.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
|
||||
"github.com/sst/opencode/pkg/app"
|
||||
"github.com/sst/opencode/pkg/server"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
|
||||
cwd, _ := os.Getwd()
|
||||
app, err := app.New(ctx, cwd)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
server, err := server.New(app)
|
||||
|
||||
var wg errgroup.Group
|
||||
wg.Go(func() error {
|
||||
defer stop()
|
||||
return server.Start(ctx)
|
||||
})
|
||||
|
||||
<-ctx.Done()
|
||||
|
||||
wg.Wait()
|
||||
}
|
||||
Reference in New Issue
Block a user