-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dev/speedup_coin_to_string
- Loading branch information
Showing
7 changed files
with
205 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Pre-Upgrade Handling | ||
|
||
Cosmovisor supports custom pre-upgrade handling. Use pre-upgrade handling when you need to implement application config changes that are required in the newer version before you perform the upgrade. | ||
|
||
Using Cosmovisor pre-upgrade handling is optional. If pre-upgrade handling is not implemented, the upgrade continues. | ||
|
||
For example, make the required new-version changes to `app.toml` settings during the pre-upgrade handling. The pre-upgrade handling process means that the file does not have to be manually updated after the upgrade. | ||
|
||
Before the application binary is upgraded, Cosmovisor calls a `pre-upgrade` command that can be implemented by the application. | ||
|
||
The `pre-upgrade` command does not take in any command-line arguments and is expected to terminate with the following exit codes: | ||
|
||
|
||
| Exit status code | How it is handled in Cosmosvisor | | ||
|------------------|---------------------------------------------------------------------------------------------------------------------| | ||
| `0` | Assumes `pre-upgrade` command executed successfully and continues the upgrade. | | ||
| `1` | Default exit code when `pre-upgrade` command has not been implemented. | | ||
| `30` | `pre-upgrade` command was executed but failed. This fails the entire upgrade. | | ||
| `31` | `pre-upgrade` command was executed but failed. But the command is retried until exit code `1` or `30` are returned. | | ||
|
||
|
||
## Sample | ||
|
||
Here is a sample structure of the `pre-upgrade` command: | ||
|
||
```go | ||
func preUpgradeCommand() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "pre-upgrade", | ||
Short: "Pre-upgrade command", | ||
Long: "Pre-upgrade command to implement custom pre-upgrade handling", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
|
||
err := HandlePreUpgrade() | ||
|
||
if err != nil { | ||
os.Exit(30) | ||
} | ||
|
||
os.Exit(0) | ||
|
||
}, | ||
} | ||
|
||
return cmd | ||
} | ||
``` | ||
|
||
|
||
Ensure that the pre-upgrade command has been registered in the application: | ||
```go | ||
rootCmd.AddCommand( | ||
// .. | ||
preUpgradeCommand(), | ||
// .. | ||
) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters