shadow/cmd/run.go

38 lines
693 B
Go

/*
Copyright © 2024 Shane C. <shane@scaffoe.com>
*/
package cmd
import (
"git.shadowhosting.xyz/shadow/utils"
"github.com/gofiber/fiber/v2"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"golang.org/x/sys/unix"
"os"
"os/signal"
)
// runCmd represents the run command
var runCmd = &cobra.Command{
Use: "run",
Short: "Runs the main service",
Run: func(cmd *cobra.Command, args []string) {
if viper.GetBool("dev") && !fiber.IsChild() {
utils.RunViteServer()
sc := make(chan os.Signal, 1)
signal.Notify(sc, unix.SIGINT, unix.SIGTERM, os.Interrupt)
<-sc
}
if !viper.GetBool("dev") {
utils.Webserver()
}
},
}
func init() {
rootCmd.AddCommand(runCmd)
}