rewrite into go and nextjs
This commit is contained in:
58
cmd/junk2jive/main.go
Normal file
58
cmd/junk2jive/main.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"gitea.miguelmuniz.com/rogueking/junk2jive-server/internal/config"
|
||||
"gitea.miguelmuniz.com/rogueking/junk2jive-server/internal/handlers"
|
||||
"gitea.miguelmuniz.com/rogueking/junk2jive-server/internal/routes"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Parse command line flags
|
||||
var configPath string
|
||||
flag.StringVar(&configPath, "config", "", "Path to config file")
|
||||
flag.Parse()
|
||||
|
||||
// If no config file specified, look for it in default locations
|
||||
if configPath == "" {
|
||||
// Check current directory
|
||||
if _, err := os.Stat("config.json"); err == nil {
|
||||
configPath = "config.json"
|
||||
} else {
|
||||
// Check config directory relative to executable
|
||||
exePath, err := os.Executable()
|
||||
if err == nil {
|
||||
potentialPath := filepath.Join(filepath.Dir(exePath), "../config/config.json")
|
||||
if _, err := os.Stat(potentialPath); err == nil {
|
||||
configPath = potentialPath
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Load configuration
|
||||
cfg, err := config.Load(configPath)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to load configuration: %v", err)
|
||||
}
|
||||
|
||||
// Initialize services
|
||||
// This would initialize your OpenAI and Robowflow services
|
||||
// based on your configuration
|
||||
|
||||
// Set up the router
|
||||
router := routes.SetupRoutes(cfg)
|
||||
|
||||
// Start the server
|
||||
addr := fmt.Sprintf("%s:%d", cfg.Server.Host, cfg.Server.Port)
|
||||
log.Printf("Starting server on %s", addr)
|
||||
if err := http.ListenAndServe(addr, router); err != nil {
|
||||
log.Fatalf("Failed to start server: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user