node-selector not working with nest.js all of a sudden

tomfree

Member
Oct 26, 2022
7
1
3
Munich
cPanel Access Level
Website Owner
I am trying to run my nest.js app by


function log(s: any) {
fs.appendFileSync('./serverStart.log', JSON.stringify(s) + "\n");
}
async function bootstrap() {
try {
const app = await NestFactory.create(AppModule);
log("app created")
app.setGlobalPrefix('api');
log("app set prefix")
await app.listen(0);
log("started")
} catch (e) {
log(e);
}
}
bootstrap();


that works nicely locally and used to work nicely with cpanel node-selector at my hoster until two days ago when I suspect my hoster changed sth, though they deny it. However now I get the follwowing error in my log file
{"errno":-17,"code":"EEXIST","syscall":"uv_pipe_open"}

I am not sure what to make of it and a search did not result in anything meaningfull? Any ideas someone?
Simple erxpress works like the one below work at my hoster


var http = require('http');
var server = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
var response = "All good";
res.end(response);
});
server.listen();


So it seems to be some interworking between cpanel and nest.js and as said the apps works nicely on my machine (with a dedicated port - cpanel howver requires auto-assignment if understand it right and it used to work)

Cheers Tom

ps: sorry about the formatting. Couldnt get code formatting to work right.
 

tomfree

Member
Oct 26, 2022
7
1
3
Munich
cPanel Access Level
Website Owner
UpdatE: I investigated further and found

calling $ node /home/dasdding/nestbasic/dist/main.js the app is nicely started on my hosters environment

"starting "
[Nest] 879990 - 11/25/2022, 5:21:05 PM LOG [NestFactory] Starting Nest application...
[Nest] 879990 - 11/25/2022, 5:21:05 PM LOG [InstanceLoader] AppModule dependencies initialized +33ms
[Nest] 879990 - 11/25/2022, 5:21:05 PM LOG [InstanceLoader] HttpModule dependencies initialized +4ms
[Nest] 879990 - 11/25/2022, 5:21:05 PM LOG [InstanceLoader] MetricsModule dependencies initialized +0ms
[Nest] 879990 - 11/25/2022, 5:21:05 PM LOG [InstanceLoader] TerminusModule dependencies initialized +1ms
[Nest] 879990 - 11/25/2022, 5:21:05 PM LOG [InstanceLoader] HealthModule dependencies initialized +0ms
"create app "
"prefix done"
"init done"
[Nest] 879990 - 11/25/2022, 5:21:05 PM LOG [RoutesResolver] HealthController {/nestbasic/health}: +5ms
[Nest] 879990 - 11/25/2022, 5:21:05 PM LOG [RouterExplorer] Mapped {/nestbasic/health, GET} route +2ms
[Nest] 879990 - 11/25/2022, 5:21:05 PM LOG [RouterExplorer] Mapped {/nestbasic/health/storage, GET} route +1ms
[Nest] 879990 - 11/25/2022, 5:21:05 PM LOG [RouterExplorer] Mapped {/nestbasic/health/memory, GET} route +0ms
[Nest] 879990 - 11/25/2022, 5:21:05 PM LOG [RouterExplorer] Mapped {/nestbasic/health/main4shops, GET} route +1ms
[Nest] 879990 - 11/25/2022, 5:21:05 PM LOG [RoutesResolver] MetricsController {/nestbasic/metrics}: +0ms
[Nest] 879990 - 11/25/2022, 5:21:05 PM LOG [RouterExplorer] Mapped {/nestbasic/metrics, GET} route +0ms
[Nest] 879990 - 11/25/2022, 5:21:05 PM LOG [NestApplication] Nest application successfully started +3ms
"now listening "
"http://[::1]:45611"

Buit when starting it via capnel i still get the error. According to What is EINVAL in Linux? this EINVAL means invalid argument passed.

So I check what arguments are being passed and found it to be ["/opt/alt/alt-nodejs16/root/usr/bin/node","/usr/local/lsws/fcgi-bin/lsnode.js"]

Comparing that to the call when I just run node ..../main.js I see a difference. Running node .../main.js as expected I get
["/opt/alt/alt-nodejs16/root/usr/bin/node","/home/dasdding/nestbasic/dist/main.js"]

Doing a cat /usr/local/lsws/fcgi-bin/lsnode.js I see that the script executed by cpanel is not directly my script but sth that appears to be some sort of a wrapper that mentions " Copyright 2002-2018 Lite Speed Technologies Inc, All Rights Reserved. * LITE SPEED PROPRIETARY/CONFIDENTIAL" I.e. from an pp developers perspective that knows his app but not cpanel wrapping cpanel is not calling my script but doing sth different that results in an invalid parameter exeception.

Since previously nest.js and cpanel worked together and now they dont I conclude that this is a incompatibility between cpanel and nest.js that must have recently been introduced, since it worked before (config change or code - not sure).

Since in my deployment of my app I use the defined versions in the package-lock of packages and install via npm ci (thus using the exact versions from the package-lock and tried deployment with a commit if package-lock where it worked I conclude that it is most likey a recent chagne in cpanel/node-selector config or code. Or do I misunderstand npm ci and package-lock,json working together?

To me it seems sth must have changed in a recent cpanel version and now cpanel and nest.js are not compatible anymore. Opinions? Happy to hear otherwise!!

Cheers
Tom
 

tomfree

Member
Oct 26, 2022
7
1
3
Munich
cPanel Access Level
Website Owner
Hey there! If your CloudLinux license is purchased through us, please submit a ticket to our team so we can take a look at this directly on the system.
Thanks. Am checking with my hoster - since I just purchased a manged service from them and they probably have the contract with you. Finger crossed...
 
  • Like
Reactions: cPRex