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

Module configuration is not loaded #260

Open
Jswk1 opened this issue Aug 26, 2019 · 3 comments
Open

Module configuration is not loaded #260

Jswk1 opened this issue Aug 26, 2019 · 3 comments

Comments

@Jswk1
Copy link

Jswk1 commented Aug 26, 2019

Hello. I'm having problems with module development using latest @pm2/io version 4.2.6. Previously I've been using the deprecated Pmx module https://github.com/keymetrics/pmx and it worked correctly with the same code.

This is my startup code for module:

import * as Pmx from "@pm2/io";

Pmx.initModule({
    type: "generic",
    el: {
        probes: false,
        actions: true
    },
    block: {
        actions: true,
        cpu: true,
        mem: true
    }
}, (err, config) => {
//...
});

The config object in Pmx.initModule callback is some default configuration and it doesn't contain my settings neither from package.json nor module_conf.json file:

{ widget:
{ type: 'generic',
logo: 'https://app.keymetrics.io/img/logo/keymetrics-300.png',
theme: [ '#111111', '#1B2228', '#807C7C', '#807C7C' ] },
type: 'generic',
el: { probes: false, actions: true },
block: { actions: true, cpu: true, mem: true },
isModule: true,
module_conf: {},
apm: { type: 'node', version: '4.2.6' },
module_version: '3.5.1',
module_name: 'pm2',
description: 'Production process manager for Node.JS applications with a built-in load balancer.' }

I have the config section in my package.json of my module package and the same config in module_conf.json file in the section of my module name.

Is there anything else that should be done to load configuration?

@Jswk1
Copy link
Author

Jswk1 commented Sep 12, 2019

Even the pm2-logrotate still uses the deprecated Pmx module where it works correctly and it also works correctly in my case.

From my brief debugging I was able to find out that the config is loaded correctly in the Pmx.init method but not Pmx.initModule. The config is loaded in Configuration.init and sent to PM2 but the module process is never refreshed with these settings for some reason.

@Huzzle
Copy link

Huzzle commented Aug 20, 2022

Configuration.findPackageJson returns wrong path to package.json file. It tries to resolve a path based on require.main.filename and it contains path to ProcessContainerFork.js file and as a result @pm2/io parses package.json file of pm2 package instead of a module one.

@ClikeX
Copy link

ClikeX commented Dec 30, 2022

Is there any update on this issue?

I think most if not all of the modules [listed on the website}(https://pm2.io/docs/plus/guide/modules/) still use the deprecated pmx library because of this issue.

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

3 participants