-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initialized with Ignite CLI * spaceship * use a pkg to deal with ssh connections * add shh deploy and dev logic * remove unused binary check * fix cmds * remove development mode * remove unused methods * initChain flag * add runner script * check os and arch and get logs * fix remote logs * remove exported var * fix script * fix the local tmp folder * add comments * add tarball extractor * add changelog and readme * skip tests * add arch map and improve readme * add upload progress bar * unknow hosts * unkown host --------- Co-authored-by: Developer Experience team at Ignite <hello@ignite.com>
- Loading branch information
Showing
18 changed files
with
3,527 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ use ( | |
./hermes | ||
./appregistry | ||
./rollkit | ||
./spaceship | ||
) |
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,5 @@ | ||
# Spaceship App Changelog | ||
|
||
## [`v0.1.0`](https://github.com/ignite/apps/releases/tag/spaceship/v0.1.0) | ||
|
||
* First release of the Spaceship app compatible with Ignite >= v28.x.y |
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,86 @@ | ||
# Spaceship | ||
|
||
Spaceship is an Ignite App designed to extend the [Ignite CLI](https://github.com/ignite/cli) by providing tools to | ||
deploy blockchain applications via SSH. | ||
|
||
## Prerequisites | ||
|
||
* Ignite CLI: Version v28.4.0 or higher is required. | ||
* Blockchain Scaffold: A blockchain scaffolded using Ignite | ||
|
||
## Usage | ||
|
||
Spaceship provides multiple ways to connect to your SSH server for deployment: | ||
|
||
```sh | ||
ignite spaceship deploy root@127.0.0.1 --key $HOME/.ssh/id_rsa | ||
ignite spaceship deploy 127.0.0.1 --user root --key $HOME/.ssh/id_rsa | ||
ignite spaceship deploy 127.0.0.1 --user root --password password | ||
ignite spaceship deploy root@127.0.0.1 --key $HOME/.ssh/id_rsa --key-password key_password | ||
``` | ||
|
||
Each command initiates a build of the blockchain binary and sets up the chain's home directory based on the | ||
configuration. The app then connects to the specified SSH server, establishes workspaces, transfers the binary, and | ||
executes it using a runner script. The workspaces are organized under $HOME/workspace/<chain-id> and include: | ||
|
||
- Binary Directory: $HOME/workspace/<chain-id>/bin - Contains the chain binary. | ||
- Home Directory: $HOME/workspace/<chain-id>/home - Stores chain data. | ||
- Log Directory: $HOME/workspace/<chain-id>/log - Holds logs of the running chain. | ||
- Runner Script: $HOME/workspace/<chain-id>/run.sh - A script to start the binary in the background using nohup. | ||
- PID File: $HOME/workspace/<chain-id>/spaceship.pid - Stores the PID of the currently running chain instance. | ||
|
||
### Managing the Chain | ||
|
||
To manage your blockchain deployment, use the following commands: | ||
|
||
- Check Status: | ||
|
||
```sh | ||
ignite spaceship status root@127.0.0.1 --key $HOME/.ssh/id_rsa | ||
``` | ||
|
||
- View Logs: | ||
|
||
```sh | ||
ignite spaceship log root@127.0.0.1 --key $HOME/.ssh/id_rsa | ||
``` | ||
|
||
- Restart the Chain: | ||
|
||
```sh | ||
ignite spaceship restart root@127.0.0.1 --key $HOME/.ssh/id_rsa | ||
``` | ||
|
||
- Stop the Chain: | ||
|
||
```sh | ||
ignite spaceship stop root@127.0.0.1 --key $HOME/.ssh/id_rsa | ||
``` | ||
|
||
To redeploy the chain on the same server without overwriting the home directory, use the --init-chain flag to | ||
reinitialize the chain if necessary. | ||
|
||
### Config | ||
|
||
You can override the default [chain configuration](https://docs.ignite.com/references/config#validators) by using the | ||
Ignite configuration file. Validators' node configuration files are stored in the data directory. By default, Spaceship | ||
initializes the chain locally in a temporary folder using the Ignite config file and then copies the configuration to | ||
the remote machine at $HOME/workspace/<chain-id>/home. | ||
Configuration resets are performed by Ignite when necessary, especially when using the --init-chain flag or if the chain | ||
was not previously initialized. | ||
|
||
Example Ignite config: | ||
|
||
``` | ||
validators: | ||
- name: alice | ||
bonded: '100000000stake' | ||
app: | ||
pruning: "nothing" | ||
config: | ||
moniker: "mychain" | ||
client: | ||
output: "json" | ||
``` | ||
|
||
For more information, please refer to the [Ignite documentation](https://docs.ignite.com). |
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,84 @@ | ||
package cmd | ||
|
||
import "github.com/ignite/cli/v28/ignite/services/plugin" | ||
|
||
var defaultFlags = []*plugin.Flag{ | ||
{ | ||
Name: flagUser, | ||
Shorthand: "u", | ||
Usage: "ssh user", | ||
Type: plugin.FlagTypeString, | ||
}, | ||
{ | ||
Name: flagPort, | ||
Shorthand: "p", | ||
Usage: "ssh port", | ||
Type: plugin.FlagTypeString, | ||
}, | ||
{ | ||
Name: flagPassword, | ||
Usage: "ssh user password", | ||
Type: plugin.FlagTypeString, | ||
}, | ||
{ | ||
Name: flagKey, | ||
Shorthand: "k", | ||
Usage: "ssh key", | ||
Type: plugin.FlagTypeString, | ||
}, | ||
{ | ||
Name: flagRawKey, | ||
Shorthand: "r", | ||
Usage: "ssh raw key", | ||
Type: plugin.FlagTypeString, | ||
}, | ||
{ | ||
Name: flagKeyPassword, | ||
Usage: "ssh key password", | ||
Type: plugin.FlagTypeString, | ||
}, | ||
} | ||
|
||
// GetCommands returns the list of spaceship app commands. | ||
func GetCommands() []*plugin.Command { | ||
return []*plugin.Command{ | ||
{ | ||
Use: "spaceship [command]", | ||
Short: "spaceship is an awesome Ignite application!", | ||
Commands: []*plugin.Command{ | ||
{ | ||
Use: "deploy", | ||
Short: "deploy your chain", | ||
Flags: append(defaultFlags, | ||
&plugin.Flag{ | ||
Name: flagInitChain, | ||
Shorthand: "i", | ||
Usage: "run init chain and create the home folder", | ||
Type: plugin.FlagTypeBool, | ||
}, | ||
), | ||
}, | ||
{ | ||
Use: "log", | ||
Short: "get chain logs if its running", | ||
Flags: defaultFlags, | ||
}, | ||
{ | ||
Use: "status", | ||
Short: "get chain status if its running", | ||
Flags: defaultFlags, | ||
}, | ||
{ | ||
Use: "restart", | ||
Short: "restart your chain", | ||
Flags: defaultFlags, | ||
}, | ||
{ | ||
Use: "stop", | ||
Short: "stop your chain", | ||
Flags: defaultFlags, | ||
}, | ||
}, | ||
}, | ||
} | ||
} |
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,81 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/ignite/cli/v28/ignite/services/plugin" | ||
|
||
"github.com/ignite/apps/spaceship/cmd" | ||
) | ||
|
||
func main() { | ||
home, err := os.UserHomeDir() | ||
if err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
return | ||
} | ||
var ( | ||
args = os.Args | ||
ctx = context.Background() | ||
chainInfo = &plugin.ChainInfo{ | ||
AppPath: filepath.Join(home, "Desktop/go/src/github.com/ignite/mars"), | ||
ChainId: "mars", | ||
} | ||
c = &plugin.ExecutedCommand{ | ||
Use: args[1], | ||
Path: "ignite spaceship " + args[1], | ||
Args: []string{fmt.Sprintf("%s@127.0.0.1", filepath.Base(home))}, | ||
OsArgs: os.Args, | ||
With: nil, | ||
Flags: []*plugin.Flag{ | ||
{ | ||
Name: "key", | ||
Shorthand: "k", | ||
Usage: "ssh key", | ||
Type: plugin.FlagTypeString, | ||
Value: filepath.Join(home, ".ssh/id_rsa"), | ||
}, | ||
{ | ||
Name: "init-chain", | ||
Shorthand: "i", | ||
Usage: "run init chain and create the home folder", | ||
Type: plugin.FlagTypeBool, | ||
Value: "true", | ||
}, | ||
}, | ||
} | ||
) | ||
switch args[1] { | ||
case "deploy": | ||
if err := cmd.ExecuteSSHDeploy(ctx, c, chainInfo); err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
return | ||
} | ||
case "log": | ||
if err := cmd.ExecuteSSHLog(ctx, c, chainInfo); err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
return | ||
} | ||
case "status": | ||
if err := cmd.ExecuteSSHStatus(ctx, c, chainInfo); err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
return | ||
} | ||
case "restart": | ||
if err := cmd.ExecuteSSHRestart(ctx, c, chainInfo); err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
return | ||
} | ||
case "stop": | ||
if err := cmd.ExecuteSSHSStop(ctx, c, chainInfo); err != nil { | ||
fmt.Fprintln(os.Stderr, err) | ||
return | ||
} | ||
default: | ||
fmt.Fprintf(os.Stderr, "unknown command: %s", args[1]) | ||
return | ||
} | ||
} |
Oops, something went wrong.