Can't deploy directus

Hi, i am trying to deploy our directus 10 repository for last 3 days.

At first i got error on Link Media Uploads + Activate New Deployment hook. It fixed when i changed package manager to pnpm. And build command to pnpx directus bootstrap, afterwards deployment completed successful but i got 502 error and couldn’t access to the site whatever i do. Then i changed the pm2’s config…

from:

script: “./cleavr.runner.js”,
args: “start”,

to:

script: “pnpx”,
args: “directus start”,

Then 502 error been solved and i can access to the website. But i noticed my cpu usage is around 80~90% constantly. My repository is pretty simple and has 3 files in it…

snapshot.yaml
pnpm-lock.yaml
package.json

I am not applying snapshot with deployment hooks so only important file is package.json and it contains:

{
“scripts”: {
“start”: “pnpx directus start”,
“build”: “pnpx directus bootstrap”,
},
“dependencies”: {
“directus”: “^10.1.1”,
“mysql”: “^2.18.1”,
“pg”: “^8.11.0”
},
}

I can’t see any error log, even though i tried other solutions for other bugs in the forum like adding “type”:“module” etc… Also i checked the cleavr’s example repository in github GitHub - cleavr/directus-example: Example Directus application but even deploying that repository causes same errors. Am i doing something wrong? really confused here…

Dear @Lynx,

We apologize for any inconvenience this has caused.

We are aware that high CPU usage can be an issue with the ecosystem config you are using. To help prevent this, we have implemented the runner file as the start script.

We are currently investigating the matter and will be in touch with you to discuss how we can be of assistance.

1 Like

Hello @Lynx,

For more background on the runner file, you can check out this thread: Node JS, PM2, and running apps in cluster mode - FIXED! - #3 by amiedema

For the issue you are experiencing, I’ve tried to repro using our Directus example you mentioned - here is the repo / branch directus/package.json at 4268f51eb3b04c114cd7da747b5487189f5befcb · armgitaar/directus · GitHub .

I added in the details you are using and I did get a 502 for a bit but then adding "type": "module" seemed to clear it up.

Hopefully, that helps in troubleshooting. If your project is public, let us know and we can try deploying it on a test server.

@amiedema I seriously started to think the custom server that i brought in to cleavr is faulty here, This is the public repo GitHub - LynxTR/directus-0d12m i forked from our private repository. Only additional config is pnpm install deployment hook. And the domain is: https://dtrbrctheyzbk8dd6925.cleaver.live

Appears to be something with pnpm. If I deploy using normal npm install hook it works fine. I found this error when using pnpm

0|gye0ptwv | You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
0|gye0ptwv | TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension "" for /home/cleavr/gye0ptwvvudg6ips7884.cleaver.rocks/releases/20230523034129613/node_modules/.bin/directus
0|gye0ptwv |     at new NodeError (node:internal/errors:399:5)
0|gye0ptwv |     at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:79:11)
0|gye0ptwv |     at defaultGetFormat (node:internal/modules/esm/get_format:121:38)
0|gye0ptwv |     at defaultLoad (node:internal/modules/esm/load:81:20)
0|gye0ptwv |     at nextLoad (node:internal/modules/esm/loader:163:28)
0|gye0ptwv |     at ESMLoader.load (node:internal/modules/esm/loader:605:26)
0|gye0ptwv |     at ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:22)
0|gye0ptwv |     at new ModuleJob (node:internal/modules/esm/module_job:64:26)
0|gye0ptwv |     at #createModuleJob (node:internal/modules/esm/loader:480:17)
0|gye0ptwv |     at ESMLoader.getModuleJob (node:internal/modules/esm/loader:434:34)

I see… So first, I got an error from type:module, then pnpm… Thank you so much for the help!