mirror of
https://codeberg.org/shroff/phylum.git
synced 2026-01-05 19:21:23 -06:00
[server] Allow setting working directory
This commit is contained in:
@@ -28,6 +28,8 @@ func SetupCommand() {
|
||||
var rootCmd = &cobra.Command{Use: path.Base(os.Args[0])}
|
||||
flags := rootCmd.PersistentFlags()
|
||||
|
||||
flags.StringP("workdir", "W", "", "Set working directory")
|
||||
|
||||
flags.Bool("debug", false, "Debug mode")
|
||||
flags.MarkHidden("debug")
|
||||
viper.BindPFlag("debug", flags.Lookup("debug"))
|
||||
@@ -46,6 +48,11 @@ func SetupCommand() {
|
||||
|
||||
uuid.EnableRandPool()
|
||||
rootCmd.PersistentPreRun = func(cmd *cobra.Command, args []string) {
|
||||
dir, _ := cmd.Flags().GetString("workdir")
|
||||
if dir != "" && dir != "." {
|
||||
logrus.Info("Changing directory to " + dir)
|
||||
os.Chdir(dir)
|
||||
}
|
||||
if viper.GetBool("debug") {
|
||||
logrus.SetLevel(logrus.TraceLevel)
|
||||
logrus.Debug("Running in debug mode")
|
||||
|
||||
@@ -28,7 +28,7 @@ func createEngine(config *viper.Viper) *gin.Engine {
|
||||
|
||||
if config.GetBool("cors.enabled") {
|
||||
origins := config.GetStringSlice("cors.origins")
|
||||
logrus.Info("Enabling cors. Origins: " + strings.Join(origins, ", "))
|
||||
logrus.Info("Enabling cors (" + strings.Join(origins, ", ") + ")")
|
||||
engine.Use(cors.New(cors.Config{
|
||||
AllowOrigins: origins,
|
||||
AllowHeaders: []string{"Origin", "Authorization", "Accept", "Accept-Language", "Content-Type"},
|
||||
|
||||
Reference in New Issue
Block a user