1

Trying to upload my project to openlitespeed. However, encountering difficulties.

Basic Node setup is that:

const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World form node js app.js\n');
});

server.listen(port, hostname, () => {
  console.log(`Server running at http://${hostname}:${port}/`);
});

Have a look at how to include Modules as below:

var http = require('http');
var dt = require('./myfirstmodule');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/html'});
  res.write("The date and time are currently: " + dt.myDateTime());
  res.end();
}).listen(8080);

But, I can basicly run my Nuxtjs project on local host.

What is the possible expected result:

Running Nuxtjs application on VPS which is upcloud with a startup file for having seen serving it on openlitespeed.

Have checked here, but no info on openlitespeeed deployment: https://nuxtjs.org/docs/2.x/deployment/nginx-proxy

Bitfinicon
  • 1,045
  • 1
  • 8
  • 22
  • 1
    Found a similar framwork (Starapi) run on OpenLiteSpeed guide, https://docs.litespeedtech.com/cloud/images/nodejs/#how-do-i-set-up-strapi hope it helps. – Eric Feb 05 '21 at 09:01
  • Hi Eric, thanks, have checked it already. The problem is that I can't make nuxtjs app start on litespeed. It starts from linux and it doesn't listen to started port and gives error "the port is already on use" – Bitfinicon Feb 06 '21 at 05:59
  • For inst: In order to run on node instead of npm run start, you will need some JavaScript. Execute the following to add a start.js script to the Strapi app folder:and there is a script to start strapi on Express. Would be great to have a script to start Nuxtjs just like Strapi starting script – Bitfinicon Feb 06 '21 at 06:24
  • 1
    Agree, but I'm not sure about the start script for NuxtJS too, let's see if other people know it. – Eric Feb 15 '21 at 23:48
  • 1
    Have found the solution. Use pm2, it is fine and consistent – Bitfinicon Feb 23 '21 at 22:33

1 Answers1

1

Hi it was pretty easy after some research:

https://nuxtjs.org/docs/2.x/deployment/deployment-pm2

copy this file named ecosystem.config.js file in which it has these codes to Root folder of Nuxt:

module.exports = {
    apps: [
      {
        name: 'NuxtAppName',
        exec_mode: 'cluster',
        instances: 'max', // Or a number of instances
        script: './node_modules/nuxt/bin/nuxt.js',
        args: 'start'
      }
    ]
  }

Run on your linux:

killall node
cd /usr/local/lsws/serverclient/client
pm2 start

Good to go

Bitfinicon
  • 1,045
  • 1
  • 8
  • 22