Skip to content

Commit

Permalink
Fix: CLI Version with PM2/Commander (Unsupported)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanlelek committed Apr 11, 2023
1 parent 56496a0 commit 19605c2
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 13 deletions.
51 changes: 40 additions & 11 deletions bin/raneto
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
#!/usr/bin/env node

// ################################
// ########## DEPRECATED ##########
// ################################
// PM2 is not officially recommended for
// production use by Raneto authors.
// Consider alternatives like systemd instead.
// This has been kept for the time being
// for those that use it and others that
// don't want to use systemd

// ###################
// ##### WARNING #####
// ###################
// This can only be used when installing development modules
// Additionally, the logs will only output the first process
// and not multiple process logs. This should be easy to fix
// by looping through the output but is not developed/tested

// Hide Keymetrics banner on first time PM2 is required
// var consoleLog = console.log;
// console.log = function () {};
Expand All @@ -9,6 +27,7 @@ var pm2 = require('pm2');
// Modules
var path = require('path');
var program = require('commander');
var Tail = require('tail').Tail;
var pkg = require('../package.json');

process.chdir(path.normalize(path.join(__dirname, '..')));
Expand All @@ -22,12 +41,15 @@ program
pm2.connect(() => {
pm2.start(
{
script: path.normalize(
path.join(__dirname, '..', 'example', 'server.js')
),
script: path.normalize(path.join(__dirname, '..', 'server.js')),
exec_mode: 'fork',
instances: 1,
name: 'raneto',
env: {
PORT: 3000,
NODE_ENV: 'development',
DEBUG: 'raneto*',
},
},
// (error, apps)
(error) => {
Expand Down Expand Up @@ -98,14 +120,21 @@ program
console.log('Raneto not running');
process.exit(0);
} else {
// var log = new Tail(list[0].pm2_env.pm_out_log_path, '\n', { interval : 500 });
// var error_log = new Tail(list[0].pm2_env.pm_err_log_path, '\n', { interval : 500 });
// log.on('line', function (data) {
// console.log(data);
// });
// error_log.on('line', function (data) {
// console.log(data);
// });
var log = new Tail(list[0].pm2_env.pm_out_log_path, '\n', {
interval: 500,
});
var error_log = new Tail(list[0].pm2_env.pm_err_log_path, '\n', {
interval: 500,
});
console.log('##### WARNING! THIS FEATURE IS UNTESTED #####');
console.log('FILEOUT', list[0].pm2_env.pm_out_log_path);
console.log('FILEERR', list[0].pm2_env.pm_err_log_path);
log.on('line', function (data) {
console.log(data);
});
error_log.on('line', function (data) {
console.log(data);
});
}
});
});
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"dependencies": {
"@raneto/theme-default": "0.0.1",
"body-parser": "1.20.2",
"commander": "9.5.0",
"commander": "10.0.0",
"cookie-parser": "1.4.6",
"debug": "4.3.4",
"express": "4.18.2",
Expand Down Expand Up @@ -89,6 +89,7 @@
"mocha": "10.2.0",
"pm2": "5.3.0",
"prettier": "2.8.7",
"supertest": "6.3.3"
"supertest": "6.3.3",
"tail": "2.2.6"
}
}

0 comments on commit 19605c2

Please sign in to comment.