2022-08-31 07:52:43 +00:00
|
|
|
package start
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
"github.com/zitadel/logging"
|
|
|
|
|
|
|
|
"github.com/zitadel/zitadel/cmd/key"
|
|
|
|
"github.com/zitadel/zitadel/cmd/setup"
|
|
|
|
"github.com/zitadel/zitadel/cmd/tls"
|
|
|
|
)
|
|
|
|
|
2023-04-24 17:40:31 +00:00
|
|
|
func NewStartFromSetup(server chan<- *Server) *cobra.Command {
|
2022-08-31 07:52:43 +00:00
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "start-from-setup",
|
|
|
|
Short: "cold starts zitadel",
|
|
|
|
Long: `cold starts ZITADEL.
|
|
|
|
First the initial events are created.
|
|
|
|
Last ZITADEL starts.
|
|
|
|
|
|
|
|
Requirements:
|
|
|
|
- database
|
|
|
|
- database is initialized
|
|
|
|
`,
|
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
err := tls.ModeFromFlag(cmd)
|
|
|
|
logging.OnError(err).Fatal("invalid tlsMode")
|
|
|
|
|
|
|
|
masterKey, err := key.MasterKey(cmd)
|
|
|
|
logging.OnError(err).Panic("No master key provided")
|
|
|
|
|
|
|
|
setupConfig := setup.MustNewConfig(viper.GetViper())
|
|
|
|
setupSteps := setup.MustNewSteps(viper.New())
|
|
|
|
setup.Setup(setupConfig, setupSteps, masterKey)
|
|
|
|
|
|
|
|
startConfig := MustNewConfig(viper.GetViper())
|
|
|
|
|
2023-04-24 17:40:31 +00:00
|
|
|
err = startZitadel(startConfig, masterKey, server)
|
2022-08-31 07:52:43 +00:00
|
|
|
logging.OnError(err).Fatal("unable to start zitadel")
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
startFlags(cmd)
|
|
|
|
setup.Flags(cmd)
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|