Tutorial: How to setup a Sting chat node

in HiveDevslast year

As you're probably aware, we have recently integrated Sting chat onto actifit.io's experience (check the announcement post here
We find Sting chat quite useful for expanding and better interconnecting hive communities and our very own actifit users, top that with being easily customizable (Props to peakd team for a job well done!)

We also loved the fact that Sting chat supports running multiple nodes, so we decided to run our own node in support of helping it grow and decentralizing it further.

This is a tutorial about running your own sting chat API node:

image.png

Server Requirements

Server requirements are quite minimal.
We are currently running our node on ubuntu 22.04 LTS, with a 4 core CPU, 8 GB RAM, and 200 GB SSD (sting chat only consumes so far less than 1 GB)

Steps

Below are the detailed steps for getting things rolling:

pull up updates to your server and install git

sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt install git -y

install nodejs

sudo apt install nodejs

install yarn

corepack enable
corepack prepare yarn@stable --activate
yarn --version
yarn set version stable

setup project

yarn

clone the stingchat repo to your server

git clone https://gitlab.com/peakd/sting-message-backend
cd sting-message-backend

install postgres

sudo apt install postgresql postgresql-contrib

start the service

sudo systemctl start postgresql.service

connect to postgres account and set a new password

sudo -i -u postgres
psql
\password postgres

create db (we used the name stgchat for it)

createdb stgchat

first run/sync (make sure to switch YOUR_PASS with the postgres account pass. Also if you used a different db name,ports use those instead. NETNAME param is the name of a public node hosted by peakd team. More details about params available here. You could edit the .env file for setting up all the configurations for sting chat, or pass them as params to the command.

yarn buildlib
PORT=3001 DATABASE_URL="postgres://postgres:YOUR_PASS@localhost:5432/stgchat" NETNAME="main[STM7RgJh7MsuADocKQPrwpbDSAkA8bWbkvMmxoM7xR86QqC8ugFyj]" NODES="https://chat-api.peakd.com" CLONE_URL="https://chat-api.peakd.com" yarn run start

after sync is complete, you can stop the process.
now let's setup pm2 to make it easier to use, and then perform the official run

npm install -g pm2
pm2 start --name stingchat "PORT=3001 DATABASE_URL='postgres://postgres:YOUR_PASS@localhost:5432/stgchat' NETNAME='main[STM7RgJh7MsuADocKQPrwpbDSAkA8bWbkvMmxoM7xR86QqC8ugFyj]' NODES='https://chat-api.peakd.com' yarn run start"

install caddy if you wish to hook up a sub/domain to your server or for better server management

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

point caddy to your 3001 (or whichever port you are running on)

nano /etc/caddy/Caddyfile
#enable below in file
reverse_proxy localhost:3001
#reload caddy
systemctl reload caddy

and you're all set! Your API node should be accessible now via your_ip/api/info or your_domain/api/info, similarly to https://sting.actifit.io/api/info


rulersig2.jpg

Sort:  

PIZZA!
The Hive.Pizza team manually curated this post.

Join us in Discord!

we love this

Buena 💪👏 gracias