2022-03-28 08:05:09 +00:00
|
|
|
package start
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/spf13/viper"
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/logging"
|
2022-05-30 11:38:30 +00:00
|
|
|
|
2022-06-27 10:32:34 +00:00
|
|
|
"github.com/zitadel/zitadel/cmd/initialise"
|
|
|
|
"github.com/zitadel/zitadel/cmd/key"
|
|
|
|
"github.com/zitadel/zitadel/cmd/setup"
|
|
|
|
"github.com/zitadel/zitadel/cmd/tls"
|
2022-03-28 08:05:09 +00:00
|
|
|
)
|
|
|
|
|
2023-04-24 17:40:31 +00:00
|
|
|
func NewStartFromInit(server chan<- *Server) *cobra.Command {
|
2022-03-28 08:05:09 +00:00
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "start-from-init",
|
|
|
|
Short: "cold starts zitadel",
|
|
|
|
Long: `cold starts ZITADEL.
|
|
|
|
First the minimum requirements to start ZITADEL are set up.
|
|
|
|
Second the initial events are created.
|
|
|
|
Last ZITADEL starts.
|
|
|
|
|
|
|
|
Requirements:
|
|
|
|
- cockroachdb`,
|
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
2022-06-24 12:38:22 +00:00
|
|
|
err := tls.ModeFromFlag(cmd)
|
|
|
|
logging.OnError(err).Fatal("invalid tlsMode")
|
|
|
|
|
2022-04-12 14:20:17 +00:00
|
|
|
masterKey, err := key.MasterKey(cmd)
|
|
|
|
logging.OnError(err).Panic("No master key provided")
|
|
|
|
|
2024-01-04 16:12:20 +00:00
|
|
|
initialise.InitAll(cmd.Context(), initialise.MustNewConfig(viper.GetViper()))
|
2022-03-28 08:05:09 +00:00
|
|
|
|
|
|
|
setupConfig := setup.MustNewConfig(viper.GetViper())
|
|
|
|
setupSteps := setup.MustNewSteps(viper.New())
|
2022-04-12 14:20:17 +00:00
|
|
|
setup.Setup(setupConfig, setupSteps, masterKey)
|
2022-03-28 08:05:09 +00:00
|
|
|
|
|
|
|
startConfig := MustNewConfig(viper.GetViper())
|
|
|
|
|
2024-01-04 16:12:20 +00:00
|
|
|
err = startZitadel(cmd.Context(), startConfig, masterKey, server)
|
2022-03-28 08:05:09 +00:00
|
|
|
logging.OnError(err).Fatal("unable to start zitadel")
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
startFlags(cmd)
|
2022-04-25 15:05:20 +00:00
|
|
|
setup.Flags(cmd)
|
2022-03-28 08:05:09 +00:00
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|