Hi Joseph, I have been trying everything from the links you provided but I am still having issues.
When I ssh in and run ‘serve -s build’, I get the following error:
file:///usr/lib/node_modules/serve/build/main.js:235
throw new Error(Failed to serve: ${error2.stack?.toString() ?? error2.message}
);
^
Error: Failed to serve: Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (node:net:1740:16)
at listenInCluster (node:net:1788:12)
at Server.listen (node:net:1876:7)
at file:///usr/lib/node_modules/serve/build/main.js:247:14
at new Promise ()
at startServer (file:///usr/lib/node_modules/serve/build/main.js:245:10)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///usr/lib/node_modules/serve/build/main.js:517:40
at Server. (file:///usr/lib/node_modules/serve/build/main.js:235:11)
at Server.emit (node:events:513:28)
at emitErrorNT (node:net:1767:8)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
This is my ‘app.js’ file:
import express from ‘express’
const app = express();
import path from ‘path’
import { fileURLToPath } from ‘url’;
import { dirname } from ‘path’;
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
import bodyParser from ‘body-parser’
import cookieParser from ‘cookie-parser’
const port = 3000
import Sequelize from ‘sequelize’
import sequelize from “./config/database.js”;
import ejs from ‘ejs’
import ejsLint from ‘ejs-lint’
import expressLayouts from ‘express-ejs-layouts’
import mainRoutes from “./routes/mainroute.js”;
app.use(express.json())
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, ‘/public’)));
app.use(cookieParser());
// Connect all the routes to my app
app.use(mainRoutes)
// EJS
app.set(‘views’, path.join(__dirname, ‘views’));
app.set(‘view engine’, ‘ejs’);
// Test connection to database
sequelize
.authenticate()
.then(() => {
console.log(‘Connected to database successfully.’);
})
.catch(err => {
console.error(‘Unable to connect to the database:’, err);
});
sequelize.sync()
.then(() => {
console.log(‘Tables created if it does not already exist’);
}).catch(err => {
console.log(‘Table has not been created’);
});
app.listen(port, () => {
console.log(Connected to server on port ${port}
)
})
And this is the vHost Conf file:
docRoot $VH_ROOT/public_html
vhDomain $VH_NAME
vhAliases www.$VH_NAME
adminEmails [email protected]
enableGzip 1
enableIpGeo 1
index {
useServer 0
indexFiles index.php, index.html
}
errorlog $VH_ROOT/logs/$VH_NAME.error_log {
useServer 0
logLevel WARN
rollingSize 10M
}
accesslog $VH_ROOT/logs/$VH_NAME.access_log {
useServer 0
logFormat “%h %l %u %t “%r” %>s %b “%{Referer}i” “%{User-Agent}i””
logHeaders 5
rollingSize 10M
keepDays 10
compressArchive 1
}
scripthandler {
add lsapi:sicil5304 php
}
extprocessor sicil5304 {
type lsapi
address UDS://tmp/lshttpd/sicil5304.sock
maxConns 10
env LSAPI_CHILDREN=10
initTimeout 600
retryTimeout 0
persistConn 1
pcKeepAliveTimeout 1
respBuffer 0
autoStart 1
path /usr/local/lsws/lsphp81/bin/lsphp
extUser sicil5304
extGroup sicil5304
memSoftLimit 2047M
memHardLimit 2047M
procSoftLimit 400
procHardLimit 500
}
phpIniOverride {
php_admin_value open_basedir “/tmp:$VH_ROOT”
}
module cache {
storagePath /usr/local/lsws/cachedata/$VH_NAME
}
rewrite {
enable 1
autoLoadHtaccess 1
}
context / {
type appserver
location /home/mydomain.co.uk/public_html
binPath /usr/bin/node
appType node
maxConns 100
rewrite {
}
addDefaultCharset off
}
Even if I change the IndexFiles to ‘app.js’, my preview link just loads and loads until it times out.
Sorry for all the information but I know that there is something that I might be overlooking but can’t quite get to it!