This commit is contained in:
Josh at WLTechBlog
2025-08-12 10:19:13 -05:00
parent 70d9ed30de
commit d6209cd34f
16 changed files with 4118 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
package main
import (
"flag"
"fmt"
"log"
"os"
"os/signal"
"syscall"
"git.teamworkapps.com/shortcut/cremote/daemon"
)
var (
daemonHost = flag.String("listen", "localhost", "Listen address")
port = flag.Int("port", 8989, "Listen port")
)
func main() {
flag.Parse()
// Create and start the daemon
d, err := daemon.NewDaemon(*daemonHost, *port)
if err != nil {
log.Fatalf("Failed to create daemon: %v", err)
}
// Handle graceful shutdown
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-sigChan
fmt.Println("Shutting down daemon...")
d.Stop()
}()
// Start the daemon (this blocks until the server is stopped)
log.Printf("Starting daemon on port %d", *port)
if err := d.Start(); err != nil {
log.Fatalf("Failed to start daemon: %v", err)
}
}