How to configure Node JS?

Hello,
I installed the wowonder script on a clean server on which I installed the Hestiacp control panel
It is a social networking script.
The script developer recommends using NodeJS to receive messages and notifications via chat directly and to reduce the load on the server by 80%.
But the instructions in the documentation are insufficient on how to configure it.
This is a picture of inside the control panel of what is required.
Can you advise how to configure NodeJS

As shown in the picture, the path to the security certificate files is correct for .key and .crt?


Here is a link to the published documentation with the script that explains the overall configuration method.
Documentation | WoWonder
Best Regards.

what issue you are facing? You facing issue with installation of NodeJS setup?

1 Like

Thank you for your interest.
The script basically works perfectly with port 80 of localhost, but the script developer recommends using the NodeJS-based extension, which is located in a subfolder within the script folders. Below are images of the script files:

Here is the startup file for the extension:

The extension does not contain the app.sock file

The full path to the startup file:
/home/user/web/domain/public_html/nodejs/main.js

The developer of the script says that activating the NodeJS extension will allow messages, calls, and notifications to arrive in real time, and it reduces the load on server resources by 80%, whereas if it is turned off, notifications will arrive slowly, or when the page is refreshed, or they may not arrive at all.

What is required is the correct way to configure NodeJS so that the plugin works along with the script.

The developer of the script says that activating the NodeJS extension will allow messages, calls, and notifications to arrive in real time, and it reduces the load on server resources by 80%, whereas if it is turned off, notifications will arrive slowly, or when the page is refreshed, or they may not arrive at all.

The following image shows the options available within the script to enable or disable NodeJS.

NodeJS is now activated in the dashboard, but messages and notifications do not work. If it is stopped, they will work, but sometimes they arrive and sometimes they do not, and notifications do not appear unless the page is refreshed.

  • What is required is the correct way to configure NodeJS so that the plugin works along with the script.

  • My other question was: Are the paths shown in the following image for the SSL certificate correct, as it is a required option for NodeJS to work with the https protocol?

dude, do it separatly from hestia. just intall NodeJS, npm, pm2 properly. then run the script in background via pm2, with auto restart. on specific port which is not in use [no need to configure SSL, because which method i am telling, it will apply ssl automatically].

then install docker and docker compose properly in your system.
go to cloudflare zero trust, create an new tunnel, click on docker, copy the command and add “-d” at last [also add autorestart policy if you want].

then go to cloudflare zero trust > tunnel > select created tunnel [make sure status is active] > click on configure > add your website with http and ip port and select domain > save it.

congratulations!

please DM me if you want more help!

1 Like

Let me thank you.
I don’t use Cloudflare.
Today I already installed NodeJS, npm, pm2
And I opened ports 3000 and 449 in hestia firewall
When I execute the run command, I see the status online.
pm2 start main.js

While when I execute the command
pm2 list

I see the status errored
I tried to read the log using the command
pm2 logs main [--lines 1000]
I saw the following errors


[TAILING] Tailing last 15 lines for [main] process (change the value with --lines option)
/root/.pm2/logs/main-out.log last 15 lines:
/root/.pm2/logs/main-error.log last 15 lines:
0|main     | Require stack:
0|main     | - /home/user/web/domain.com/public_html/nodejs/main.js
0|main     |     at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
0|main     |     at Hook._require.Module.require (/usr/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:81:25)
0|main     |     at require (node:internal/modules/helpers:130:18)
0|main     |     at Object.<anonymous> (/home/user/web/domain.com/public_html/nodejs/main.js:1:16)
0|main     |     at Module._compile (node:internal/modules/cjs/loader:1241:14)
0|main     |     at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
0|main     |     at Module.load (node:internal/modules/cjs/loader:1091:32)
0|main     |     at Module._load (node:internal/modules/cjs/loader:938:12)
0|main     |     at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
0|main     |     at Module._compile (node:internal/modules/cjs/loader:1241:14) {
0|main     |   code: 'MODULE_NOT_FOUND',
0|main     |   requireStack: [ '/home/user/web/domain.com/public_html/nodejs/main.js' ]
0|main     | }


0|main  | Error: Cannot find module 'moment'
0|main  | Require stack:
0|main  | - /home/user/web/domain.com/public_html/nodejs/main.js
0|main  |     at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
0|main  |     at Hook._require.Module.require (/usr/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:81:25)
0|main  |     at require (node:internal/modules/helpers:130:18)
0|main  |     at Object.<anonymous> (/home/user/web/domain.com/public_html/nodejs/main.js:1:16)
0|main  |     at Module._compile (node:internal/modules/cjs/loader:1241:14)
0|main  |     at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
0|main  |     at Module.load (node:internal/modules/cjs/loader:1091:32)
0|main  |     at Module._load (node:internal/modules/cjs/loader:938:12)
0|main  |     at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
0|main  |     at Module._compile (node:internal/modules/cjs/loader:1241:14) {
0|main  |   code: 'MODULE_NOT_FOUND',
0|main  |   requireStack: [ '/home/user/web/domain.com/public_html/nodejs/main.js' ]
0|main  | }
0|main  | Error: Cannot find module 'moment'
0|main  | Require stack:
0|main  | - /home/user/web/domain.com/public_html/nodejs/main.js
0|main  |     at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
0|main  |     at Hook._require.Module.require (/usr/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:81:25)
0|main  |     at require (node:internal/modules/helpers:130:18)
0|main  |     at Object.<anonymous> (/home/user/web/domain.com/public_html/nodejs/main.js:1:16)
0|main  |     at Module._compile (node:internal/modules/cjs/loader:1241:14)
0|main  |     at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
0|main  |     at Module.load (node:internal/modules/cjs/loader:1091:32)
0|main  |     at Module._load (node:internal/modules/cjs/loader:938:12)
0|main  |     at Object.<anonymous> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
0|main  |     at Module._compile (node:internal/modules/cjs/loader:1241:14) {
0|main  |   code: 'MODULE_NOT_FOUND',
0|main  |   requireStack: [ '/home/user/web/domain.com/public_html/nodejs/main.js' ]
0|main  | }

npm -g -f install moment

1 Like

I already fixed it
The status is now online even after rebooting.
But notifications still do not arrive, nor do messages from one person to another in the chat.
Also, I opened the ports in Hestia

I also see the following error when reading the error log:


PM2        | 2023-10-21T15:41:08: PM2 log: App [main:1] online

/root/.pm2/logs/main-out.log last 15 lines:
/root/.pm2/logs/pm2-sysmonit-out.log last 15 lines:
/root/.pm2/logs/pm2-sysmonit-error.log last 15 lines:
/root/.pm2/logs/main-error.log last 15 lines:
1|main     |   syscall: 'read',
1|main     |   code: 'EISDIR'
1|main     | }
1|main     | Error: EISDIR: illegal operation on a directory, read
1|main     |     at Object.readSync (node:fs:735:3)
1|main     |     at tryReadSync (node:fs:420:20)
1|main     |     at Object.readFileSync (node:fs:471:19)
1|main     |     at loadConfig (/home/user/web/domain.com/public_html/nodejs/main.js:50:15)
1|main     |     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
1|main     |     at async init (/home/user/web/domain.com/public_html/nodejs/main.js:121:3)
1|main     |     at async main (/home/user/web/domain.com/public_html/nodejs/main.js:128:3) {
1|main     |   errno: -21,
1|main     |   syscall: 'read',
1|main     |   code: 'EISDIR'
1|main     | }

also opened port from, server provider?

1 Like

Do you mean data center?
There are no rules in the data center firewall
Server from Hetzner

Unless you run it under it under root /home/user/conf/web/ is not accessible by the user …

1 Like

Do you mean copy nodejs folder to this directory?
/home/user/conf/web/nodejs

then
pm2 start main.js

Yes, the problem has been fixed by creating a folder and copying the SSL certificate files to it:
/home/$user/web/hatssl/$user.com.key
Is there a way to grant the account access to the main folder of the SSL certificate?
/home/$user/conf/web/$domain/ssl
The SSL certificate will no longer be valid after 3 months and its files must be replaced.

Try creating an symbolic link…

2 Likes

Worked

ln -s source_file myfile

Thank you

1 Like

Buenas noches, me alegro que halla resuelto el tema del script “Wowonder” a mi me fascina.
Usted lo utiliza con nginx como servidor solamente o con apache2 de servidor web y nginx de proxy inverso (aparte de NodeJS para ambos la mensajerĂ­a como vĂ­).
Si lo utiliza con nginx de servidor web podrías compartir el archivo de configuración del script, yo aún no he podido ponerlo a trabajar…
Gracias y disculpe la molestia…

Hello,
I used this configuration to install Hestia This will make nginx running in the background side by side with Apache.

cd /root
wget https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install.sh
bash hst-install.sh -a yes -w yes -o yes -v yes -j no -k yes -m yes -g yes -x yes -z yes -Z no -c yes -t yes -i yes -b yes -q yes -d yes -l yes -y yes

You must install nodjs and npm then pm2

apt install nodejs
apt install npm
npm install pm2 -g
cd /home/user/web/domain.com/public_html/nodejs/
pm2 start main.js
pm2 set pm2:sysmonit true
pm2 update
pm2 startup
pm2 save

Now execute the following command, you should see the startup file online status in green:
pm2 list

Now the SSL certificate folder must be linked to a place where the user can read it by creating a symbolic link:

ln -s /home/user/conf/web/domain.com/ssl /home/user/web/domain.com

In the script dashboard, under Settings, go to NodeJs Configuration and enter the following paths, making sure to change the username and domain:

/home/user/web/domain.com/ssl/domain.com.key
/home/user/web/domain.com/ssl/domain.com.crt

Allow ports 3000 and 449 to the Hestia firewall.

Please note: that these settings allowed chat to run in the script, but messages and notifications do not arrive in real time. I am now in the process of contacting developer support for the script to find out the reason behind this.

Hope this helps, If you need more assistance, do not hesitate to ask.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.