Skip to content

Commit

Permalink
Merge pull request #91 from cheqd/feature/node-install-instruction-im…
Browse files Browse the repository at this point in the history
…provements

Node install instruction improvements
  • Loading branch information
askolesov authored Aug 6, 2021
2 parents 107e7c0 + 8ef7305 commit 4232a66
Show file tree
Hide file tree
Showing 6 changed files with 229 additions and 188 deletions.
2 changes: 0 additions & 2 deletions build_tools/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,4 @@ EOF
# Reload daemons for systemctl
systemctl daemon-reload

# Enable cheqd-noded
systemctl enable cheqd-noded
fi
75 changes: 46 additions & 29 deletions docs/deb-package-installation.md → docs/deb-package-overview.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,55 @@
## Overview
One of the possible distribution way is to use debian package.
It's the most common way for Ubuntu OS and also it can provide post-install steps which can help to make our application as a service.
Because we have to run init procedure for creating tree of directories, `configs` and `data`, not all the steps can be automated.
By the way, debian package consists of binary, named `cheqd-noded` and script with post-install and post-remove actions.
# Overview of changes that `deb` package does


Debian package is the most common way for Ubuntu OS and also it can provide post-install steps which can help to make our application to run as a service.

The package consists of:
- Binary, named `cheqd-noded`;
- Script with post-install and post-remove actions.

## Post-install actions
### Create a special user "cheqd"

### System user creation

By default, cosmos-sdk create all needed directories in the `HOME` directory.
That's why package creates a special user with home directory `/var/lib/cheqd`. Also, this user will use for setting permissions to data and configs.
That's why package creates a special `cheqd` user with home directory set to `/var/lib/cheqd`.

### Directories and symlinks

### Dividing configs, data and logs
#### Directories
According to general filesystem hierarchy standard (FHS), the next directories will be created:
```
/etc/cheqd-node - configs, permissions cheqd:cheqd
/var/lib/cheqd/data - data , permissions cheqd:cheqd
/var/log/cheqd-node - logs , permissions syslog:adm (set by rsyslog)
```

After setting up the node, it's expected, then configs and data will be symlinked to the corresponded system directories.
For this purposes will be created the next symlinks to configs and data:
```
sudo ln -s /etc/cheqd-node/ /var/lib/cheqd/.cheqdnode/config - for configs
sudo ln -s /var/lib/cheqd/data /var/lib/cheqd/.cheqdnode/ - for data
```
- `/etc/cheqd-node`
- Configuration files location
- Permissions: `cheqd:cheqd`
- `/var/lib/cheqd/data`
- Place for blockchain data
- Permissions: cheqd:cheqd
- `/var/log/cheqd-node`
- Place for logs
- Permissions: syslog:adm (set by rsyslog)

After this preparation, it would be possible to set up cheqd node in general but under `cheqd` user.
The following symlinks will be created:

- `/etc/cheqd-node/` -> `/var/lib/cheqd/.cheqdnode/config`
- For configs
- `/var/lib/cheqd/data` -> `/var/lib/cheqd/.cheqdnode/data`
- For data

### Rsyslog configuration

#### Rsyslog config
The next config for rsyslog will be created:

```
if \$programname == 'cheqd-noded' then /var/log/cheqd-node/stdout.log
& stop
```

It redirects all the logs into the file.
#### Logrotate config
For rotating log file will be used `logrotate` - the general approach for Linux/systemd with the next config:

### Logrotate config

For rotating log file will be used `logrotate` - the general approach for Linux/systemd with the following config:

```
/var/log/cheqd-node/stdout.log {
rotate 30
Expand All @@ -46,13 +60,16 @@ For rotating log file will be used `logrotate` - the general approach for Linux/
maxage 30
}
```

It means, that log will be rotated after achieving 100 Mb size of `stdout.log` and compressed.
All the archives will be stored for a month (30 days). Also, the main file will truncated instead of removing. It needs for continue logging process in terms of file pointers.

Once a day by crontab will be called a small script for running logrotate logic.

### Systemd
The main part of post-installation process is making our binary as a service. Systemd service file can help with it:
## Systemd

The main part of post-installation process is making our binary as a service. The following systemd service file will be created:

```
[Unit]
Description=Service for running Cheqd node
Expand All @@ -73,13 +90,13 @@ SyslogIdentifier=cheqd-noded
[Install]
WantedBy=multi-user.target
```
The main thing here is that it will restart on binary failures and put all output to the `rsyslog`.

## Exposing port

The main thing here is that it will restart on binary failures and put all output to the `rsyslog`.

## Post-remove actions

For now, all files created during installation process will be removed from the system, like:

```
/etc/rsyslog.d/cheqd-node.conf
/etc/logrotate.d/cheqd-node
Expand Down
156 changes: 0 additions & 156 deletions docs/how-to-setup-a-new-node.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This document describes in detail how to join existing network as validator.

1. Setup a node:

Follow [this instruction](how-to-setup-a-new-node.md).
Follow [this instruction](setting-up-a-new-node.md).

Use corresponding `genesis.json` and `persistent peers list` form `persistent_chains` folder in the root of the repository.

Expand Down
File renamed without changes.
Loading

0 comments on commit 4232a66

Please sign in to comment.