mirror of
https://github.com/cline/cline.git
synced 2026-09-21 05:10:09 +08:00
* super sketchy big merge with main * gitignore * gitignore * Delete cli/bin/air * Delete cli/bin directory * Delete cli/cline-host * Fix missing package.json in cli Copy the package JSON into the dist-standalone dir during compilation. Remove workaround for missing package.json * Update scripts/build-cli.sh Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * Remove reference to watchservice, it has been removed * Update scripts/build-go-proto.mjs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix timestamp to string conversion * diff.go ellipsis fix * COMMON_TYPES --------- Co-authored-by: Sarah Fortune <sarah.fortune@gmail.com> Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
72 lines
1.3 KiB
Go
72 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
"os/signal"
|
|
"syscall"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/cline/cli/pkg/hostbridge"
|
|
)
|
|
|
|
var (
|
|
port int
|
|
verbose bool
|
|
)
|
|
|
|
func main() {
|
|
rootCmd := &cobra.Command{
|
|
Use: "cline-host",
|
|
Short: "Cline Host Bridge Service",
|
|
Long: `A simple host bridge service that provides host operations for Cline Core.`,
|
|
RunE: runServer,
|
|
}
|
|
|
|
rootCmd.Flags().IntVarP(&port, "port", "p", 51052, "port to listen on")
|
|
rootCmd.Flags().BoolVarP(&verbose, "verbose", "v", false, "verbose logging")
|
|
|
|
if err := rootCmd.Execute(); err != nil {
|
|
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func runServer(cmd *cobra.Command, args []string) error {
|
|
ctx := cmd.Context()
|
|
|
|
// Create gRPC hostbridge service
|
|
service := hostbridge.NewGrpcServer(port, verbose)
|
|
|
|
// Handle graceful shutdown
|
|
ctx, cancel := context.WithCancel(ctx)
|
|
defer cancel()
|
|
|
|
go func() {
|
|
sigChan := make(chan os.Signal, 1)
|
|
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
|
|
<-sigChan
|
|
|
|
if verbose {
|
|
log.Println("Shutting down hostbridge server...")
|
|
}
|
|
|
|
cancel()
|
|
}()
|
|
|
|
// Start server
|
|
if verbose {
|
|
log.Printf("Starting Cline Host Bridge on port %d", port)
|
|
}
|
|
|
|
// Run the service
|
|
if err := service.Start(ctx); err != nil {
|
|
return fmt.Errorf("failed to run service: %w", err)
|
|
}
|
|
|
|
return nil
|
|
}
|