Steemfeed-JS v3.1.0 Released - Easier to use and now HIVE Compatible!

in #hive-1395315 months ago (edited)

steemfeed-js logo

Today, I've developed and released two new versions of SteemFeed-JS, a small piece of software used by several Steem/Hive witnesses to update their price feeds.

Included in this post are instructions for both new installs, and updating existing ones.

The biggest changes since the last release:

  • Added support for multiple networks via the network config option, along with various other config options for
    adjusting both the symbols used in the exchange pair lookup, and the symbols used within the price feed JSON.

    • Currently there are only two network 's supported: hive and steem
  • Added support for the exchange Ionomy

  • Added the HIVE/BTC pair to both the Bittrex adapter, and the Ionomy adapter

  • Lots of refactoring to improve code quality (I won't bore you, check the release notes)

  • Added disable_exchanges config option, allowing you to disable one or more exchanges via config.json instead of having to edit the exchange.js code.

  • Added the config options exchanges_provide and exchanges_no_provide, which allow you to add new or remove existing pairs respectively on the built-in exchange adapters.

  • Added the publishonce command to app.js, which causes the script to publish your feed only one time, then exit.

  • Added the run.sh script, which works similarly to Steem-in-a-box's run.sh script.

  • Made various improvements to the Dockerfile

For more information, see the Github release notes for v3.0.0 and v3.1.0:

Installing Steemfeed-JS using Docker

First clone the repository using git and cd into the folder:

git clone https://github.com/Someguy123/steemfeed-js.git
cd steemfeed-js

If you don't have docker installed yet, you can easily install it using run.sh

./run.sh install_docker

(Optional) To save a little time, you can use my binary docker image, instead of having
to build the container - which takes a few minutes (vs. a few seconds via binary install)

./run.sh install

If you've ran at least one of the previous run.sh, it should have copied the example config into config.json for you :) (if not, run cp config.example.json config.json)

[email protected] ~/steemfeed-js # ls -l config*
-rw-r--r-- 1 root root 1398 Mar 21 23:16 config.advanced.json
-rw-r--r-- 1 root root  253 Mar 21 23:16 config.example.json
-rw-r--r-- 1 root root  275 Mar 21 23:17 config.json

Now open up config.json and fill it out :)

nano config.json

Most options have sensible defaults and don't need to be touched. The main settings are:

  • name (your witness name)
  • wif (your active PRIVATE key)
  • network (either "steem" or "hive")
  • interval (how often do you want to publish a feed? default is every 60 minutes)

Here's an example of a simple config for myself (obv. that's not my real active key)

{
    "name": "someguy123",
    "wif": "5JzFy1ZooZ3RDJYaN6iGhe5Y4MZ17qM6RYj9RQN1ULJtAhHRidU",
    "network": "hive",

    "interval": 60
}

Once you've finished editing your config, it's time to start it up :)

./run.sh start

Now we can check the logs to make sure it's working, using ./run.sh logs

[email protected] ~/steemfeed-js # ./run.sh logs
DOCKER LOGS: (press ctrl-c to exit)

> [email protected] start /opt/steemfeed
> node app.js publishnow

-------------
[2020-03-22T05:16:57.344Z] Loaded configuration:
Username: someguy123
Bias: Disabled
RPC Node: https://anyx.io/
-------------
[2020-03-22T05:16:57.345Z] Attempting to login into account someguy123
[2020-03-22T05:16:57.861Z] Successfully logged into someguy123

[2020-03-22T05:16:57.861Z] Publishing immediately, then every 60 minute(s)

[2020-03-22T05:16:59.882Z] HIVE/USD is: 0.187 USD per HIVE
[2020-03-22T05:16:59.882Z] Attempting to publish feed...

[2020-03-22T05:17:02.991Z] Data published at:  Sun Mar 22 2020 05:17:02 GMT+0000 (Coordinated Universal Time)
[2020-03-22T05:17:02.992Z] Successfully published feed.
[2020-03-22T05:17:02.992Z] TXID: 49e41be5f49b69fe57bd54c18f730ff543fccf85 TXNUM: 2

To ensure the feed doesn't get stuck, it's recommended to setup a cron to restart the script every so often.

To do that, enter the command:

EDITOR='nano' crontab -e

Add this line to the bottom of the cron file - the */4 means every 4 hours. You can change the 4 to another number between 1 - 24, e.g. */12 means "restart every 12 hours".

  0 */4   *   *   *    docker restart steemfeed

The bottom of your crontab should now look like this:

# For more information see the manual pages of crontab(5) and cron(8)
#
# m  h   dom mon dow   command
  0 */4   *   *   *    docker restart steemfeed

note: you don't have to align it with the 'm h dom' etc.

You're now good to go, and publishing a price feed on either Steem / Hive (depending on the network you chose)

./run.sh status     # This help you check if it's running or not.
./run.sh publish    # If you need to force update your feed at any point
./run.sh stop       # To stop the steemfeed-js container
./run.sh restart    # To restart the steemfeed-js container (e.g. after config changes / image updates)
./run.sh build      # If you don't want to / can't use my binary image, this will force build a new image locally.

Updating an existing Steemfeed-JS installation (using Docker or plain NodeJS)

To update the steemfeed-js code, enter the folder and run git pull like so:

cd ~/steemfeed-js
git pull

If you're wanting to switch your feed to be used for Hive:

  • Open up your config.json e.g. nano config.json
  • If you've got a node set, e.g. "node": "https://steemd.privex.io", - then you'll need to either remove this line,
    or change it to a Hive node such as https://anyx.io
  • Add the additional config line "network": "hive" somewhere in the file (don't forget about commas at the end of each line, apart from the last line)

Upgrading a Docker installation

If you were previously using Docker for steemfeed-js, I recommend stopping + removing your container, and removing the existing steemfeed-js image to avoid any conflicts:

# Stop and remove the default 'steemfeed' container
docker stop steemfeed
docker rm steemfeed
# Remove the built image 'steemfeed-js'
docker rmi steemfeed-js

Now you can either install my binary image, or skip this step if you'd prefer to build it (building is automatic now)

./run.sh install

Now it's time to start up the new feed software (if you skipped the binary image, then this will also automatically build an image for you):

./run.sh start

THat's it. All done.

Just check the logs to confirm it's working, then you're good to go :)

./run.sh logs

Upgrading a NodeJS installation

If you aren't running the feed with docker, then you'll need to manually stop the feed, wherever it's running, e.g. in screen or tmux.

If you're running it in a terminal session (including via screen/tmux), just hit CTRL-C to stop it.

Now, assuming you've already ran the git pull step, let's ensure you have the latest dependencies:

npm install

Once npm has finished updating any packages, just run npm start and you'll be up and running again.

npm start

Thanks for reading :)


GIF Avatar by @stellabelle


Do you like what I'm doing for Hive?

Vote for me to be a Hive witness - every vote counts.


Don't forget to follow me for more like this.


Have you ever thought about being a witness yourself? Join the witness channel. We're happy to guide you! Join in shaping the Hive economy.

Are you looking for a new server provider? My company @privex offers highly-reliable and affordable dedicated and virtual servers for EOS, LTC, and BTC! Check out our website at https://www.privex.io

You can join Privex's public Discord at https://discord.gg/5XrMuSv - we also have a Matrix server, sign up at https://riot.privex.io (or if you have an existing Matrix account, join our General chat at #privex:privex.io)


Sort:  

I'm glad to report that it's working like a charm! Great job.

image.png

Nicely done @someguy123!

Thank you for this update ! It's very nice to move the Steem JS API to Hive 😀

Thanks for this crucial update @someguy123

Thanks a lot! It works out of the box ^^