Commit 89511b8c authored by inertia's avatar inertia
Browse files

Merge branch 'node-op' into 'develop'

Node op et. al

See merge request !109
parents af858824 076eee1b
---
title: Managing a Node Using Monit
position: 6
description: |
Use monit as a utility for managing and monitoring hived.
exclude: true
layout: full
canonical_url: monit.html
---
### Intro
Monit can restart hived if it crashes, if it does not respond, or stop the process if it uses too many resources. You can use monit to monitor files, directories and filesystems for changes, such as timestamps changes, checksum changes or size changes.
One of the major benefits of monit is the ability to have hived start when the system restarts. And if monit is properly configured, you can have your system stop hived when the system shuts down.
### Sections
* [Install Monit](#install-monit)
* [Configure Monit](#configure-monit)
### Install Monit
On linux:
```bash
$ sudo apt-get install monit​
```
For other OS types, refer to: [mmonit.com/monit](https://mmonit.com/monit/)
### Configure Monit
Create file `/home/YOUR_USERNAME/hive_data/start_hived.sh`
```bash
#!/bin/bash
t=`cat /proc/uptime | cut -f 1 -d '.'`
s=30
if [ "$t" -lt "$s" ]; then
sleep $s
fi
cd /home/YOUR_USERNAME/hive_data
/bin/su YOUR_USERNAME -c "nohup /usr/bin/hived --data-dir=. > hived.log 2>&1 & echo \$! > nohup_hived.pid"
```
We check uptime because if hived starts too soon, p2p may not be available within the first few seconds of OS start. If hived starts in this state, it will freeze.
Note, we're using nohup to get the pid. But you can also configure monit to work without it by looking for hived using a matching pattern. But it's always better to execute a script rather than hived directly.
Create file `/home/YOUR_USERNAME/hive_data/stop_hived.sh`
```bash
#!/bin/bash
cd "/home/YOUR_USERNAME/hive_data"
/bin/su YOUR_USERNAME -c "/bin/kill `/bin/cat nohup_hived.pid`"
```
Make them executable:
```bash
$ chmod +x start_hived.sh​
$ chmod +x stop_hived.sh​
```
Edit the file `/etc/monit/monitrc`:
```bash
$ sudo nano /etc/monit/monitrc​
```
Edit the file as follows:
```
# uncomment these lines
set httpd port 2812 and
use address localhost # only accept connection from localhost
allow localhost # allow localhost to connect to the server
```
Add this to bottom of `/etc/monit/monitrc` (make sure to change YOUR_USERNAME to your username):
```
check process hived with pidfile /home/YOUR_USERNAME/hive_data/nohup_hived.pid
start program = "/home/YOUR_USERNAME/hive_data/start_hived.sh"
with timeout 60 seconds
stop program = "/home/YOUR_USERNAME/hive_data/stop_hived.sh"
with timeout 120 seconds
```
Test the new configuration:
```
$ sudo monit -t
```
If it looks ok, then proceed to ...
Load the new configuration:
```
$ sudo monit reload​
```
Enable the watchdog:
```
$ sudo monit start hived​
```
That's it. You only have to do the above command once.
You can check monit's status by typing below:
```
$ sudo monit status​
```
Or, for a summary view:
```
$ sudo monit summary
```
Which will return something like:
```
Monit 5.26.0 uptime: 52d 2h 55m
┌─────────────────────────────────┬────────────────────────────┬───────────────┐
│ Service Name │ Status │ Type │
├─────────────────────────────────┼────────────────────────────┼───────────────┤
│ calculon │ OK │ System │
├─────────────────────────────────┼────────────────────────────┼───────────────┤
│ hived │ OK │ Process │
└─────────────────────────────────┴────────────────────────────┴───────────────┘
```
This will keep your hived running for you (across restarts, even, no need for any cronjobs or multiplexors) and keep you from fighting with your chosen OS. Keep in mind, the default is for monit to only once a minute, so be patient if you're waiting for it to do something.
---
title: Seed Node
position: 7
description: |
Setting up a seed node.
exclude: true
layout: full
canonical_url: seed-node.html
---
### Intro
This tutorial will show how to setup the lowest possible resource seed node.
### Sections
* [Minimum Requirements](#minimum-requirements)
* [Building `hived`](#building-hived)
* [Configure Node](#configure-node)
* [Latest Block Log](#latest-block-log)
* [Sync Node](#sync-node)
* [Troubleshooting](#troubleshooting)
### Minimum Requirements
This tutorial assumes Ubuntu Server 18.04 LTS 8GB RAM and 500GB SSD/HDD.
### Building `hived`
```bash
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install autoconf automake autotools-dev bsdmainutils \
build-essential cmake doxygen gdb libboost-all-dev libreadline-dev \
libssl-dev libtool liblz4-tool ncurses-dev pkg-config python3-dev \
python3-pip nginx fcgiwrap awscli gdb libgflags-dev libsnappy-dev zlib1g-dev \
libbz2-dev liblz4-dev libzstd-dev
mkdir -p ~/src
cd ~/src
git clone --branch master https://gitlab.syncad.com/hive/hive.git
cd hive
git submodule update --init --recursive
mkdir -p build
cd build
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DLOW_MEMORY_NODE=ON \
-DCLEAR_VOTES=ON \
-DSKIP_BY_TX_ID=ON \
-DHIVE_LINT_LEVEL=OFF \
-DENABLE_MIRA=OFF \
..
make -j$(nproc)
sudo make install
```
### Configure Node
```bash
mkdir -p ~/hive_data
cd ~/hive_data
hived --data-dir=.
```
At the startup banner, press `^C` (Ctrl+C) to exit `hived`. As a side effect, a default data-dir is created. Now we can purge the empty blockchain and create `config.ini` as follows:
```bash
rm -Rf blockchain
nano config.ini
```
Then make the following changes to the generated `config.ini`:
* Enable plugins: `p2p`
* Pick a port for p2p to `2001`.
To summarize, the *changed* values are:
```ini
plugin = p2p
p2p-endpoint = 0.0.0.0:2001
```
Save `config.ini`.
#### Latest Block Log
Download the block log (optional but recommended).
```bash
cd ~/hive_data
mkdir -p blockchain
wget -O blockchain/block_log https://gtg.openhive.network/get/blockchain/block_log
hived --data-dir=. --replay-blockchain
```
### Sync Node
If you did not download the latest block log:
```bash
cd ~/hive_data
hived --data-dir=. --resync-blockchain
```
After *replay* or *resync* is complete, the console will display `Got ## transactions from ...`. It's possible to close `hived` with `^C` (Ctrl+C). Then, to start the node again:
```bash
cd ~/hive_data
hived --data-dir=.
```
### Troubleshooting<a style="float: right" href="#sections"><i class="fas fa-chevron-up fa-sm" /></a>
**Problem:** Got an error while trying to compile `hived`:
`c++: internal compiler error: Killed (program cc1plus)`
**Solution:** Add more memory or enable swap.
To enable swap (do not enable swap on a VPS like Digital Ocean):
```bash
sudo dd if=/dev/zero of=/var/swap.img bs=1024k count=4000
sudo chmod 600 /var/swap.img
sudo mkswap /var/swap.img
sudo swapon /var/swap.img
```
---
**Problem:** Got an error while replaying:
`IO error: While open a file for appending: /root/hive_data/./blockchain/rocksdb_witness_object/012590.sst: Too many open files`
**Solution:** You're using MIRA, but this tutorial recommends *not* to (`-DENABLE_MIRA=OFF`). If you really *intend* to try MIRA, you will need to set higher limits. Note, if you are also running `hived` as `root` (not recommended), you must explicitly set hard/soft nofile/nproc lines for `root` instead of `*` in `/etc/security/limits.conf`.
To set the open file limit ...
```bash
sudo nano /etc/security/limits.conf
```
Add the following lines:
```conf
* hard nofile 94000
* soft nofile 94000
* hard nproc 64000
* soft nproc 64000
```
To set the `fs.file-max` limit ...
```bash
sudo nano /etc/sysctl.conf
```
Add the following line:
```ini
fs.file-max = 2097152
```
Load the new settings:
```bash
sudo sysctl -p
```
Once you save these files, you may need to logout and login again.
......@@ -115,7 +115,7 @@ Block log should be place in `blockchain` directory below `data_dir` and node sh
Replay helps to sync blockchain in much faster rate, but as blockchain grows in size replay might also take some time to verify blocks.
There is another [trick which might help](https://github.com/steemit/steem/issues/2391) with faster sync/replay on smaller equipped servers:
There is another [trick which might help]({{ 'https://github.com/steemit/steem/issues/2391' | archived_url }}) with faster sync/replay on smaller equipped servers:
```
while :
......
......@@ -13,6 +13,9 @@ This tutorial runs on the main Hive blockchain. And accounts queried are real us
This tutorial will show the method of capturing a queried tag name and matching it to the Hive. We are using the `call` function provided by the `dhive` library to pull accounts from the Hive blockchain. A simple HTML interface is used to both capture the string query as well as display the completed search.
Also see:
* [get_account_reputations]({{ '/apidefinitions/#reputation_api.get_account_reputations' | relative_url }})
## steps
1. [**App setup**](#app-setup) Configuration of `dhive` to use the proper connection and network.
......
......@@ -13,6 +13,9 @@ This tutorial pulls a list of the most recent five user's posts from the blockch
Tutorial is demonstrates the typical process of fetching account blog posts. It is quite useful if you want to embedd your blog posts on your website these tutorial will help you achieve that goal as well. This tutorial will explain and show you how to access the **Hive** blockchain using the [@hivechain/dhive](https://gitlab.syncad.com/hive/dhive) library to build a basic blog list of posts filtered by a _tag_
Also see:
* [get_discussions_by_blog]({{ '/apidefinitions/#tags_api.get_discussions_by_blog' | relative_url }})
## Steps
1. [**Configure connection**](#Configure-connection) Configuration of dhive to use proper connection and network
......
......@@ -13,6 +13,9 @@ This tutorial runs on the main Hive blockchain. And accounts queried are real us
This tutorial will show few functions such as querying account by name and getting unclaimed rewards. We are using the `call` function provided by the `dhive` library to pull accounts from the Hive blockchain. A simple HTML interface is used to capture the account and its unclaimed balance as well as allowing interactively claim rewards.
Also see:
* [claim_reward_balance_operation]({{ '/apidefinitions/#broadcast_ops_claim_reward_balance' | relative_url }})
## Steps
1. [**App setup**](#app-setup) Setup `dhive` to use the proper connection and network.
......
......@@ -28,6 +28,9 @@ This tutorial uses the `database API` to gather account information for the curr
The only other information required is the private active key of the user.
Also see:
* [convert_operation]({{ '/apidefinitions/#broadcast_ops_convert' | relative_url }})
## Steps
1. [**Configure connection**](#connection) Configuration of `dhive` to communicate with a Hive blockchain
......
......@@ -13,6 +13,11 @@ This tutorial will show how to search for a valid account name and then create a
This tutorial will show few functions such as querying account by name and check if username is taken or available to register. We are using the `call` function provided by the `dhive` library to pull account from the Hive blockchain. We then create proper private keys for new account. A simple HTML interface is used to enter payment of account creation fee and create account right inside tutorial. We use the `account_create` function to commit the transaction to the blockchain. This function is used to create what is called a "non-discounted account". This means that the creator account needs to supply the exact `account_creation_fee` in HIVE in order for the transaction to process successfully. Currently this value is set to 3 HIVE. There is a second method of creating accounts using tokens. These are called "discounted accounts". In stead of HIVE, the `account_creation_fee` is paid in RC (resource credits). There are however a limited amount of discounted accounts that can be claimed which is decided upon by the witnesses. This account creation process is done in two steps, first claiming an account and then creating the account.
Also see:
* [account_create_operation]({{ '/apidefinitions/#broadcast_ops_account_create' | relative_url }})
* [account_create_with_delegation_operation]({{ '/apidefinitions/#broadcast_ops_account_create_with_delegation' | relative_url }})
* [claim_account_operation]({{ '/apidefinitions/#broadcast_ops_account_claim_account' | relative_url }})
## Steps
1. [**App setup**](#app-setup) Setup `dhive` to use the proper connection and network.
......
......@@ -13,6 +13,10 @@ This tutorial runs on the main Hive blockchain. And accounts queried/searched ar
This tutorial will show few functions such as querying account by name and getting account vesting balance. We then convert VESTS to HIVE POWER for convenience of user. And allow user to choose portion or all holdings of VESTS to delegate other users. A simple HTML interface is provided to capture the account with search and its VESTS balance as well as allowing interactively delegate. It should be noted that when a delegation is cancelled, the VESTS will only be available again after a 5 day cool-down period.
Also see:
* [delegate_vesting_shares_operation]({{ '/apidefinitions/#broadcast_ops_delegate_vesting_shares' | relative_url }})
* [get_vesting_delegations]({{ '/apidefinitions/#condenser_api.get_vesting_delegations' | relative_url }})
## Steps
1. [**App setup**](#app-setup) Setup `dhive` to use the proper connection and network.
......
......@@ -17,6 +17,9 @@ Tutorial is demonstrating the typical process of editing content that has been p
We are using the `broadcast.comment` function provided by `dhive` which generates, signs, and broadcast the transaction to the network. On the Hive platform, posts and comments are all internally stored as a `comment` object, differentiated by whether or not a `parent_author` exists. When there is no `parent_author`, it's a post, when there is, it's a comment. When editing a post, we need to make sure that we don't resubmit the same post over and over again, which will spam the network and adds additional cost to operate the platform. Instead we will use a package called `diff-match-patch`, which allows us to only apply changes and save resources on the Hive platform.
Also see:
* [comment_operation]({{ '/apidefinitions/#broadcast_ops_comment' | relative_url }})
## Steps
1. [**Configure testnet**](#configure-app) Testnet connection should be established with proper configurations
......
......@@ -20,6 +20,9 @@ We are using the `broadcast.json` operation provided by the `dhive` library to f
A simple HTML UI is used to capture the required information, after which the broadcast operation can be compiled.
Also see:
* [custom_json_operation]({{ '/apidefinitions/#broadcast_ops_custom_json' | relative_url }})
## Steps
1. [**Configure connection**](#connection) Configuration of `dhive` to communicate with the Hive blockchain
......
......@@ -13,6 +13,13 @@ This tutorial will show how to fetch comments made by a specific account (in thi
We are using the `get_state` function with `dhive` that returns the current state of the network as well as additional content. Each content body is written in markdown and could be submitted to the blockchain by many different applications built on top of Hive. For that reason we are using the `remarkable` npm package to parse markdown in a readable format.
Also see:
* [get discussions]({{ '/search/?q=get discussions' | relative_url }})
* [tags_api.get_discussions_by_comments]({{ '/apidefinitions/#tags_api.get_discussions_by_comments' | relative_url }})
* [condenser_api.get_discussions_by_comments]({{ '/apidefinitions/#condenser_api.get_discussions_by_comments' | relative_url }})
* [tags_api.get_discussions_by_created]({{ '/apidefinitions/#tags_api.get_discussions_by_created' | relative_url }})
* [condenser_api.get_discussions_by_created]({{ '/apidefinitions/#condenser_api.get_discussions_by_created' | relative_url }})
## Steps
1. [**App setup**](#app-setup) Configuration of `dhive` to use the proper connection and network.
......
......@@ -15,6 +15,11 @@ We focus on listing part of the content with simply UI as well as explain the mo
We are using `get_state` function with `dhive`, which is straight-forward and this function returns current state of the network as well as additional content given proper query. Each content body, as we described in previous tutorials, is written markdown and submitted to the blockchain by many applications built on top of Hive. For that reason we are using `remarkable` npm package to parse markdown in a readable format.
Also see:
* [get discussions]({{ '/search/?q=get discussions' | relative_url }})
* [tags_api.get_content_replies]({{ '/apidefinitions/#tags_api.get_content_replies' | relative_url }})
* [condenser_api.get_content_replies]({{ '/apidefinitions/#condenser_api.get_content_replies' | relative_url }})
## Steps
1. [**App setup**](#app-setup) Setup app packages
......
......@@ -23,6 +23,9 @@ The second function is `getExpiringVestingDelegations` with parameters:
2. _from time_ - The date from where the query will be run. Pending expirations clear after 7 days so it will never be older than that. This value can however be set to anytime before the 7 days of expiration and it will return the relevant transactions
3. _limit_ - The quantity of results that is queried from the blockchain
Also see:
* [condenser_api.get_vesting_delegations]({{ '/apidefinitions/#condenser_api.get_vesting_delegations' | relative_url }})
## Steps
1. [**Configure connection**](#connection) Configuration of `dhive` to communicate with a Hive blockchain
......
......@@ -20,6 +20,11 @@ We are using the `call` operation provided by the `dhive` library to pull the fo
A simple HTML interface is used to capture the required information after which the function is executed.
Also see:
* [condenser_api.get_following]({{ '/apidefinitions/#condenser_api.get_following' | relative_url }})
* [condenser_api.get_followers]({{ '/apidefinitions/#condenser_api.get_followers' | relative_url }})
* [condenser_api.get_follow_count]({{ '/apidefinitions/#condenser_api.get_follow_count' | relative_url }})
## Steps
1. [**Configure connection**](#connection) Configuration of `dhive` to communicate with the Hive blockchain
......
......@@ -15,6 +15,13 @@ We will also explain the most commonly used fields from the response object as w
Each post might have comments/replies that is interesting and contributes to the topic and discussion. Hive offers out of box API for pulling replies for particular post with `get_content_replies`. We will fetch replies and list them in simple user interface.
Also see:
* [get discussions]({{ '/search/?q=get discussions' | relative_url }})
* [database_api.find_comments]({{ '/apidefinitions/#database_api.find_comments' | relative_url }})
* [condenser_api.get_content]({{ '/apidefinitions/#condenser_api.get_content' | relative_url }})
* [tags_api.get_content_replies]({{ '/apidefinitions/#tags_api.get_content_replies' | relative_url }})
* [condenser_api.get_content_replies]({{ '/apidefinitions/#condenser_api.get_content_replies' | relative_url }})
## Steps
1. [**Fetching posts**](#fetching-posts) Getting trending posts
......
......@@ -15,6 +15,11 @@ We will also explain the most commonly used fields from the response object as w
Accounts have unique `permlink` - permanent link for each of their posts. And Hive blockchain provides API to directly fetch current state of the post and its details. We will be using `get_content` to retrieve additional details. We can easily reformat data in a way that fits out application.
Also see:
* [get discussions]({{ '/search/?q=get discussions' | relative_url }})
* [database_api.find_comments]({{ '/apidefinitions/#database_api.find_comments' | relative_url }})
* [condenser_api.get_content]({{ '/apidefinitions/#condenser_api.get_content' | relative_url }})
## Steps
1. [**Fetching posts**](#fetch-posts) Trending posts list
......
......@@ -22,6 +22,9 @@ A `filter` in Hive is a kind of built-in 'view' or ordering of posts. You can us
`trending`, `hot`, `new`, `active`, and `promoted`. You'll get a feel for the subtleties of each as you create your
application.
Also see:
* [get discussions]({{ '/search/?q=get discussions' | relative_url }})
## Steps
1. [**UI**](#UI) - A brief description of the UI and inputting our query values
......
......@@ -15,6 +15,11 @@ We will also explain the most commonly used fields from the response object.
Each post has voters that support content and play big role in reward distribution. Getting details of each voter and their vote value, time, etc. is another crucial information for authors and app developers. We will be using `get_active_votes` API call to retrieve that information right from Hive blockchain.
Also see:
* [get discussions]({{ '/search/?q=get discussions' | relative_url }})
* [tags_api.get_active_votes]({{ '/apidefinitions/#tags_api.get_active_votes' | relative_url }})
* [condenser_api.get_active_votes]({{ '/apidefinitions/#condenser_api.get_active_votes' | relative_url }})
## Steps
1. [**Fetching posts**](#fetching-posts) Get trending post list
......
......@@ -33,6 +33,9 @@ The only other information required is the username of the account that the acti
The tutorial is set up with three individual functions for each of the required operations - checking permission status, granting permission and revoking permission.
Also see:
* [account_update_operation]({{ '/apidefinitions/#broadcast_ops_account_update' | relative_url }})
## Steps
1. [**Configure connection**](#connection) Configuration of `dhive` to communicate with a Hive blockchain
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment