Skip to content

Commit

Permalink
add arch map and improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantani committed Aug 1, 2024
1 parent af0c035 commit c698709
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 22 deletions.
75 changes: 54 additions & 21 deletions spaceship/README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,86 @@
# Spaceship

Spaceship is an Ignite App designed to extend the [Ignite CLI](https://github.com/ignite/cli) and assist developers in deploying their blockchain via SSH.
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.
* A blockchain scaffolded by Ignite.
* Ignite CLI: Version v28.4.0 or higher is required.
* Blockchain Scaffold: A blockchain scaffolded using Ignite

## Usage

Spaceship offers several ways to connect to your SSH server:
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
OR
ignite spaceship deploy 127.0.0.1 --user root --key $HOME/.ssh/id_rsa
OR
ignite spaceship deploy 127.0.0.1 --user root --password password
OR
ignite spaceship deploy root@127.0.0.1 --key $HOME/.ssh/id_rsa --key-password key_password
```

Each time you run this command, the binary is built, and the chain home folder is created based on the chain configuration.
The app then connects to the server via SSH, creates workspaces, transfers the binary, and runs it using a runner script.
The workspaces are created in `$HOME/workspace/<chain-id>` and consist of the following elements:
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:

- `$HOME/workspace/<chain-id>/bin` - The directory containing the chain binary.
- `$HOME/workspace/<chain-id>/home` - The chain home folder.
- `$HOME/workspace/<chain-id>/log` - Logs of the running chain.
- `$HOME/workspace/<chain-id>/run.sh` - Runner script to run the binary in the background using nohup.
- `$HOME/workspace/<chain-id>/spaceship.pid` - The PID of the currently running chain.
- 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:

To check the status of your chain, use:
```sh
ignite spaceship status root@127.0.0.1 --key $HOME/.ssh/id_rsa
```

To view the chain logs, use:
- View Logs:

```sh
ignite spaceship log root@127.0.0.1 --key $HOME/.ssh/id_rsa
```

To stop the running chain, use:
- 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
```

If you need to redeploy the chain on the same server, the home folder will not be overwritten. To reinitialize the chain, use the --init-chain flag.
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.

Learn more about Ignite in the respective documentation:
Example Ignite config:

```
validators:
- name: alice
bonded: '100000000stake'
app:
pruning: "nothing"
config:
moniker: "mychain"
client:
output: "json"
```

* <https://docs.ignite.com>
For more information, please refer to the [Ignite documentation](https://docs.ignite.com).
2 changes: 1 addition & 1 deletion spaceship/cmd/debug/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func main() {
Shorthand: "k",
Usage: "ssh key",
Type: plugin.FlagTypeString,
Value: "/Users/danilopantani/.ssh/id_rsa",
Value: filepath.Join(home, ".ssh/id_rsa"),
},
{
Name: "init-chain",
Expand Down
17 changes: 17 additions & 0 deletions spaceship/pkg/ssh/arch.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package ssh

var archMap = map[string]string{
"x86_64": "amd64", // 64-bit x86 architecture, common in desktop and server processors
"aarch64": "arm64", // 64-bit ARM architecture, used in many mobile and embedded devices
"i386": "386", // 32-bit x86 architecture, older systems
"armv7l": "arm", // 32-bit ARM architecture, commonly used in mobile and embedded devices
"armv6l": "arm", // ARMv6 architecture, older 32-bit ARM systems
"mips": "mips", // MIPS architecture, used in embedded systems and older computing
"mipsle": "mipsle", // MIPS little-endian, a variation of MIPS
"mips64": "mips64", // 64-bit MIPS architecture, used in specialized computing environments
"mips64le": "mips64le", // 64-bit MIPS little-endian, a variation of MIPS
"ppc64": "ppc64", // 64-bit PowerPC architecture, used in servers and high-performance computing
"ppc64le": "ppc64le", // 64-bit PowerPC little-endian, a variation of PowerPC
"s390x": "s390x", // IBM System/390 architecture, used in mainframes
"riscv64": "riscv64", // 64-bit RISC-V architecture, an open-source ISA
}
3 changes: 3 additions & 0 deletions spaceship/pkg/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,9 @@ func (s *SSH) Arch(ctx context.Context) (string, error) {
if err != nil {
return "", err
}
if arch, ok := archMap[v]; ok {
v = arch
}
return strings.ToLower(v), nil
}

Expand Down

0 comments on commit c698709

Please sign in to comment.