This These are the steps for installing the redeem dashboard.
Check port availability
Connect to the SSH console.
Run the command: `ss -tuln` to check if ports 3001 and 8081 are available.
Create the redeem folder
mkdir redeem-dashboard
cd redeem-dashboardClone the redeem respositories
git clone https://github.com/openvino/redeem_dashboard.git
git clone https://github.com/openvino/openvino_redeem_notifier.gitInstall node.js
sudo dnf install nodejs -yNavigate to the notifier folder:
cd openvino_redeem_notifier
Install dependencies:
npm install
Run Test run the server with pm2
pm2 start npm --name "server" -- start
Change to the dashboard folder and install dependencies:
cd ../redeem_dashboard
npm install --forceMake a build
npm run build
Start Test start the app with pm2
pm2 start npm --name "dashboard" -- start
Check pm2 status, to see both apps running
redeem_dashboard]$ pm2 status ┌─────┬──────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐ │ id │ nameCode Block start
Edit the package.json file to reflect the correct ports:
Code Block "scripts": { "dev": "next dev --port 3002", │ namespace"build": "next build", │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu"start": "next start --port 3002", "lint": "next lint" },
Add port 3002 to the firewall
Code Block sudo firewall-cmd --zone=public --add-port=3002/tcp
Configure nginx
Code Block cd /etc/nginx/sites-available vi ferment.openvino.org.conf server { │ memserver_name ferment.openvino.org; # maintain │ user │ watching │ ├─────┼──────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤ │ 1 │ dashboardthe .well-known directory alias for renewals location /.well-known { │ default alias /usr/share/nginx/html/ferment.openvino.org/.well-known; │ N/A } │ fork location /{ │ 2291356 │ 6s │ 0proxy_pass http://64.225.10.229:3002; │ online │ 0% proxy_http_version 1.1; │ 67.7mb │ mtb proxy_set_header Upgrade $http_upgrade; │ disabled │ │ 0 proxy_set_header Host │$host; server │ default proxy_cache_bypass $http_upgrade; │ N/A } │ fork listen │443 2291031ssl; # │managed 4mby Certbot │ 0 │ onlinessl_certificate /etc/letsencrypt/live/ferment.openvino.org/fullchain.pem; # managed by Certbot │ 0% │ 87.6mb │ mtb │ disabled │ └─────┴──────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
configure pm2 to start when the server boots:
sudo env PATH=$PATH:/usr/bin /usr/local/lib/node_modules/pm2/bin/pm2 startup systemd -u mtb --hp /home/mtb
Reboot and check pm2 status again:
Code Block reboot pm2 status
Configure environmental variables, go to redeem_dashboard directory and open a editor like nano or similar with the archive ".env.local": .env.local ```
Paste the following and change db credentials if you want to point to the real db and NEXT_PUBLIC_WS_SERVER_URL should be the ip of the current project:In this instance you should be able to open the app in your browser at: [your ip]: 3001 Go ahead and log in with your metamask account and you will be able to use the app. if you check the console in the browser, you also will see the message "WebSocket connection established". It means that the two apps are correctly connected. Also, everything should be exactly the same if you perform a reboot of the server.
Configure nginx
17. Now we are goning to configure nginx. cd .. cd /etc/nginx/sites-available ``` create a file in that folder, par example "sites": ``` sudo nano sites ``` paste the following config to redirect the traffic from port 80 (or what you decide to choose) to 3001, in wich the app is running: ``` server { listen 80; listen [::]:80; server_name _; location / { proxy_pass http://localhost:3001 proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } } ``` type "cat sites", you should see the content of the file execute the following commands: ``` cd .. cd sites-enabled sudo ln -sCode Block
ls ``` You should see two files, default and sites, wich is in sinc with the one in sites-avaiable folder. Open the default file, and change the port it is listening, it has to be diferent than the port you choose in "sites" file. save and close. check if everything is correct: ``` sudo nginx -t ``` if affirmative, then restart the nginx service and check the status: ``` sudo service nginx restart sudo service nginx status ``` At this point, if you enter the ip in the browser, you should see the app running without the :3001 port (it also will work that way too)ssl_certificate_key /etc/letsencrypt/live/ferment.openvino.org/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot add_header Strict-Transport-Security "max-age=31536000" always; # managed by Certbot ssl_trusted_certificate /etc/letsencrypt/live/ferment.openvino.org/chain.pem; # managed by Certbot ssl_stapling on; # managed by Certbot ssl_stapling_verify on; # managed by Certbot } server { if ($host = ferment.openvino.org) { return 301 https://$host$request_uri; } # managed by Certbot server_name ferment.openvino.org; # maintain the .well-known directory alias for renewals location /.well-known { alias /usr/share/nginx/html/ferment.openvino.org/.well-known; } location /{ proxy_pass http://64.225.10.229:3002; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } listen 80; # managed by Certbot cd sites-enabled sudo ln -s /etc/nginx/sites-available/sites /etc/nginx/sites-enabled/sites
restart nginx
Code Block sudo nginx -t sudo service nginx restart sudo service nginx status
Update the database structure
Code Block ALTER TABLE "public"."wineries" ADD COLUMN "email" varchar, ADD COLUMN "public_key" char(42), ADD COLUMN "isAdmin" bool;
Create the ferment user
Code Block groupadd -g 2224 ferment useradd -u 2224 -g 2224 -s /sbin/nologin ferment chown -R ferment:ferment /var/bloock/ferment
Edit /etc/systemd/system/ferment.service
Code Block [Unit] Description=OpenVino Ferment dashboard After=network.target [Service] User=root WorkingDirectory=/var/bloock/ferment/redeem_dashboard ExecStart=/usr/bin/npm start Restart=always RestartSec=500ms StartLimitInterval=0 [Install] WantedBy=multi-user.target
Configure systemd to automatically start the ferment dashboard on boot:
Code Block systemctl daemon-reload systemctl enable ferment systemctl start ferment
Edit /etc/systemd/system/ferment_notifier.service
Code Block [Unit] Description=OpenVino Ferment dashboard notifier After=network.target [Service] User=ferment WorkingDirectory=/var/bloock/ferment/openvino_redeem_notifier ExecStart=/usr/bin/npm start Restart=always RestartSec=500ms StartLimitInterval=0 [Install] WantedBy=multi-user.target
Configure systemd to automatically start the ferment_notifier on boot:
Code Block systemctl daemon-reload systemctl enable ferment systemctl start ferment
Check the systemd status
Code Block # systemctl status ferment ● ferment.service - OpenVino Ferment dashboard Loaded: loaded (/etc/systemd/system/ferment.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2023-09-07 13:52:19 UTC; 41s ago Main PID: 726201 (npm start) Tasks: 40 (limit: 49224) Memory: 163.1M CGroup: /system.slice/ferment.service ├─726201 npm start ├─726212 node /var/bloock/ferment/redeem_dashboard/node_modules/.bin/next start --port 3002 ├─726223 /usr/bin/node /var/bloock/ferment/redeem_dashboard/node_modules/next/dist/compiled/jest-worker/pro> └─726234 /usr/bin/node /var/bloock/ferment/redeem_dashboard/node_modules/next/dist/compiled/jest-worker/pro> Sep 07 13:52:19 sierra systemd[1]: Started OpenVino Ferment dashboard. Sep 07 13:52:20 sierra npm[726201]: > openvino-dashboard@0.1.0 start Sep 07 13:52:20 sierra npm[726201]: > next start --port 3002 Sep 07 13:52:20 sierra npm[726212]: - ready started server on 0.0.0.0:3002, url: http://localhost:3002 Sep 07 13:52:20 sierra npm[726212]: - info Loaded env from /var/bloock/ferment/redeem_dashboard/.env.local systemctl status ferment_notifier ● ferment_notifier.service - OpenVino Ferment dashboard notifier Loaded: loaded (/etc/systemd/system/ferment_notifier.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2023-09-07 18:03:20 UTC; 8s ago Main PID: 729758 (npm start) Tasks: 18 (limit: 49224) Memory: 46.5M CGroup: /system.slice/ferment_notifier.service ├─729758 npm start └─729769 node server.js Sep 07 18:03:20 sierra systemd[1]: Started OpenVino Ferment dashboard notifier. Sep 07 18:03:20 sierra npm[729758]: > server@1.0.0 start Sep 07 18:03:20 sierra npm[729758]: > node server.js Sep 07 18:03:20 sierra npm[729769]: Express server listening on port 8081
Code Block |
---|
DB_HOST= containers-us-west-156.railway.app
DB_PORT= 7131
DB_USER= postgres
DB_PASSWORD= OYrwzmuM1ckJlqkhz
DB_DATABASE= database
NEXT_PUBLIC_WS_SERVER_URL = 147.12.205.152
JWT_SECRET = "vY,aM6@^6\_\_rYMeu"
NEXT_PUBLIC_API_URL = http://147.182.25.152:3001
NEXT_AUTH_SECRET = "7CxzxhD[rQNr!g"
NEXTAUTH_URL = http://147.182.205.12:3001 |