mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-28 02:27:47 +00:00
d3bb9c9b3b
Even though this is a feature it's released as fix so that we can back port to earlier revisions. As reported by multiple users startup of ZITADEL after leaded to downtime and worst case rollbacks to the previously deployed version. The problem starts rising when there are too many events to process after the start of ZITADEL. The root cause are changes on projections (database tables) which must be recomputed. This PR solves this problem by adding a new step to the setup phase which prefills the projections. The step can be enabled by adding the `--init-projections`-flag to `setup`, `start-from-init` and `start-from-setup`. Setting this flag results in potentially longer duration of the setup phase but reduces the risk of the problems mentioned in the paragraph above. (cherry picked from commit 17953e904034e6a9d91379cab723d8dbd0f36765)
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package start
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
"github.com/zitadel/logging"
|
|
|
|
"github.com/zitadel/zitadel/cmd/initialise"
|
|
"github.com/zitadel/zitadel/cmd/key"
|
|
"github.com/zitadel/zitadel/cmd/setup"
|
|
"github.com/zitadel/zitadel/cmd/tls"
|
|
)
|
|
|
|
func NewStartFromInit(server chan<- *Server) *cobra.Command {
|
|
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) {
|
|
err := tls.ModeFromFlag(cmd)
|
|
logging.OnError(err).Fatal("invalid tlsMode")
|
|
|
|
masterKey, err := key.MasterKey(cmd)
|
|
logging.OnError(err).Panic("No master key provided")
|
|
|
|
initialise.InitAll(cmd.Context(), initialise.MustNewConfig(viper.GetViper()))
|
|
|
|
err = setup.BindInitProjections(cmd)
|
|
logging.OnError(err).Fatal("unable to bind \"init-projections\" flag")
|
|
|
|
setupConfig := setup.MustNewConfig(viper.GetViper())
|
|
setupSteps := setup.MustNewSteps(viper.New())
|
|
setup.Setup(setupConfig, setupSteps, masterKey)
|
|
|
|
startConfig := MustNewConfig(viper.GetViper())
|
|
|
|
err = startZitadel(cmd.Context(), startConfig, masterKey, server)
|
|
logging.OnError(err).Fatal("unable to start zitadel")
|
|
},
|
|
}
|
|
|
|
startFlags(cmd)
|
|
setup.Flags(cmd)
|
|
|
|
return cmd
|
|
}
|