2022-03-28 10:05:09 +02:00
|
|
|
package start
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/spf13/viper"
|
2022-04-27 01:01:45 +02:00
|
|
|
"github.com/zitadel/logging"
|
2022-05-30 13:38:30 +02:00
|
|
|
|
2022-06-27 12:32:34 +02: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 10:05:09 +02:00
|
|
|
)
|
|
|
|
|
2023-04-24 20:40:31 +03:00
|
|
|
func NewStartFromInit(server chan<- *Server) *cobra.Command {
|
2022-03-28 10:05:09 +02: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 14:38:22 +02:00
|
|
|
err := tls.ModeFromFlag(cmd)
|
|
|
|
logging.OnError(err).Fatal("invalid tlsMode")
|
|
|
|
|
2022-04-12 16:20:17 +02:00
|
|
|
masterKey, err := key.MasterKey(cmd)
|
|
|
|
logging.OnError(err).Panic("No master key provided")
|
|
|
|
|
2024-01-04 17:12:20 +01:00
|
|
|
initialise.InitAll(cmd.Context(), initialise.MustNewConfig(viper.GetViper()))
|
2022-03-28 10:05:09 +02:00
|
|
|
|
2024-01-25 17:28:20 +01:00
|
|
|
err = setup.BindInitProjections(cmd)
|
|
|
|
logging.OnError(err).Fatal("unable to bind \"init-projections\" flag")
|
|
|
|
|
2022-03-28 10:05:09 +02:00
|
|
|
setupConfig := setup.MustNewConfig(viper.GetViper())
|
|
|
|
setupSteps := setup.MustNewSteps(viper.New())
|
2024-05-30 11:35:30 +02:00
|
|
|
setup.Setup(cmd.Context(), setupConfig, setupSteps, masterKey)
|
2022-03-28 10:05:09 +02:00
|
|
|
|
|
|
|
startConfig := MustNewConfig(viper.GetViper())
|
|
|
|
|
2024-01-04 17:12:20 +01:00
|
|
|
err = startZitadel(cmd.Context(), startConfig, masterKey, server)
|
2022-03-28 10:05:09 +02:00
|
|
|
logging.OnError(err).Fatal("unable to start zitadel")
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
startFlags(cmd)
|
2022-04-25 17:05:20 +02:00
|
|
|
setup.Flags(cmd)
|
2022-03-28 10:05:09 +02:00
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|