UNPKG

1.12 kBJavaScriptView Raw
1 /**
2 * Copyright 2013-2021 the PM2 project authors. All rights reserved.
3 * Use of this source code is governed by a license that
4 * can be found in the LICENSE file.
5 */
6// Inject custom modules
7var ProcessUtils = require('./ProcessUtils')
8ProcessUtils.injectModules()
9
10if (typeof(process.env.source_map_support) != "undefined" &&
11 process.env.source_map_support !== "false") {
12 require('source-map-support').install();
13}
14
15// Rename the process
16process.title = process.env.PROCESS_TITLE || 'node ' + process.env.pm_exec_path;
17
18if (process.connected &&
19 process.send &&
20 process.versions &&
21 process.versions.node)
22 process.send({
23 'node_version': process.versions.node
24 });
25
26// Require the real application
27if (process.env.pm_exec_path) {
28 require('module')._load(process.env.pm_exec_path, null, true);
29}
30else
31 throw new Error('Could not _load() the script');
32
33// Change some values to make node think that the user's application
34// was started directly such as `node app.js`
35process.mainModule = process.mainModule || {};
36process.mainModule.loaded = false;
37require.main = process.mainModule;