CyberPanel Community

Implement a node server without using Express.js

24 replies
jo
josephgodwinke #2

Hello @Augustus

Kindly search the forum first before raising a topic

At the end you will understand to run nodejs apps.

As far as I have tested only SSG apps run without issues because you deploy them using express (this is the cyberpanel way). An SSR app can fail to run due to many issues.

As far as I see what this project is all about - its a node server running ipaddr.js under the hood. This might actually work. Also If I was you I would create .env for the server deployment since it uses port 8000 you may need to direct it to port 3000 Try deploy with pm2 see what happens

AG
Augustin Grigoras #3

I followed the steps and did

npm start

But the website only works on port 4000 how do I change it so it works on
https://domain.com/ not a port.

jo
josephgodwinke #4

Change port from 4000 to 3000 or 3001

AG
Augustin Grigoras #5

It still don’t work. It tried both 3000 and 3001.

jo
josephgodwinke #8

Then everything worked code-wise. Check your context now/ It should look something like

context / {
  type                    appserver
  location                /home/mynodejsdomain.com/public_html
  binPath                 /usr/bin/node 
  appType                 node
  maxConns                100
 
  rewrite  {
 
  }
  addDefaultCharset       off
}
AG
Augustin Grigoras #10

I did it and still doesn’t work. Also, it only works on http not https. On https it says 404 not found. In addition, I have no .htaccess file.

jo
josephgodwinke #11

Install pm2 so that you know which errors you are running into using pm2 monit. Just go to

$ cd /home/myincognitodeployment.com/public_html
$ npm -i -g pm2
$ pm2 startup src/index.js --name "incognito" --watch
$ pm2 startup && pm2 save
$ pm2 monit
AG
Augustin Grigoras #12

When I run

$ pm2 startup src/index.js --name "incognito" --watch

It gives me this error

Please verify that your choice is indeed your init system
 If you arent sure, just run : pm2 startup
-----------------------------------------------------------
/usr/local/lib/node_modules/pm2/lib/API/Startup.js:324
      throw new Error('Unknown platform / init system name');
      ^

Error: Unknown platform / init system name
    at API.CLI.startup (/usr/local/lib/node_modules/pm2/lib/API/Startup.js:324:13)
    at Command.<anonymous> (/usr/local/lib/node_modules/pm2/lib/binaries/CLI.js:707:9)
    at Command.listener (/usr/local/lib/node_modules/pm2/node_modules/commander/index.js:315:8)
    at Command.emit (node:events:513:28)
    at Command.parseArgs (/usr/local/lib/node_modules/pm2/node_modules/commander/index.js:651:12)
    at Command.parse (/usr/local/lib/node_modules/pm2/node_modules/commander/index.js:474:21)
    at Timeout._onTimeout (/usr/local/lib/node_modules/pm2/lib/binaries/CLI.js:206:15)
    at listOnTimeout (node:internal/timers:559:17)
    at processTimers (node:internal/timers:502:7)

jo
josephgodwinke #13

Run it. Which server os is this ?

AG
Augustin Grigoras #14

Now what. I did pm2 startup && pm2 save and pm2 monit

jo
josephgodwinke #15

On pm2 monit monitoring screen has your app started? do you see any errors ?

jo
josephgodwinke #18

Well that was futile.

Can you do a last try and reboot your server.

Open pm2 monit to check again give it like 10mins. PM2 is a Real-time Monitoring package it should track any Issues & Exceptions of any nodejs apps registered/saved on it.

Post your node version and npm version here still

AG
Augustin Grigoras #19

still don’t work. node v16.18.1 and npm v8.19.2.

jo
josephgodwinke #22

He used expressjs and his issue is different from yours. You are not trying to use Express.js you want use Incognito instead.

jo
josephgodwinke #24

I think its time you took this conversation to the Amethyst Network and since it uses Ultraviolet proxy as its primary proxy method (which is buggy - will make pages not even load) I would also recommend you just run SSG/SSR with Express.JS. There are several node fameworks supported out of the box which are more robust than incognito - AdonisJS, LoopbackJS etc

AG
Augustin Grigoras #25

I also realized I don’t have an .htaccess file. Do I need that?

jo
josephgodwinke #26

Yes if you want to force ssl or www redirection

Sign in to reply