Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PM2 start Fails When Command Contains "yaml" Or "json" #5945

Open
nossonCotlar opened this issue Feb 5, 2025 · 0 comments
Open

PM2 start Fails When Command Contains "yaml" Or "json" #5945

nossonCotlar opened this issue Feb 5, 2025 · 0 comments

Comments

@nossonCotlar
Copy link

I am using PM2 to manage a python web service, initiated with a bash command.
this works:

pm2 start 'cd /home/nosson/synchronize && venv/bin/uvicorn server:app --host 0.0.0.0 --reload' --name synchronize
# [PM2] Starting /usr/bin/bash in fork_mode (1 instance)
# [PM2] Done.
# ┌────┬────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
# │ id │ name           │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
# ├────┼────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
# │ 0  │ synchronize    │ default     │ N/A     │ fork    │ 4917     │ 0s     │ 0    │ online    │ 0%       │ 5.8mb    │ nosson   │ disabled │
# └────┴────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘

but when i try to specify a uvicorn log config log_config.yaml, pm2 fails to start the service:

pm2 start 'cd /home/nosson/synchronize && venv/bin/uvicorn server:app --host 0.0.0.0 --reload --log-config log_config.yaml' --name synchronize
# [PM2][ERROR] File cd /home/nosson/synchronize && venv/bin/uvicorn server:app --host 0.0.0.0 --reload --log-config log_config.yaml not found

I suspect this is due to the logic which determines if the supplied command is a pm2 config file:

pm2/lib/Common.js

Lines 283 to 294 in e3a327f

Common.isConfigFile = function (filename) {
if (typeof (filename) !== 'string')
return null;
for (let extension in Common.knonwConfigFileExtensions) {
if (filename.indexOf(extension) !== -1) {
return Common.knonwConfigFileExtensions[extension];
}
}
return null;
};

which is called when starting the service

pm2/lib/API.js

Line 328 in e3a327f

if (Common.isConfigFile(cmd) || (typeof(cmd) === 'object')) {

Logic for detecting config files as commands should be more precise, possibly checking if the entire command is a valid filename/path rather than a bash (or other) command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant