mirror of
https://github.com/Unitech/pm2.git
synced 2025-12-08 20:35:53 +00:00
Fix: Callbacks for process.stdout / .stderr (#2810)
* Fix callbacks for process.stdout /.stderr The overrides for `process.stdout.write` and `process.stderr.write` did not invoke the provided callbacks when they’re done. * Fix: write callback is an optional parameter * Append encoding parameter to all calls
This commit is contained in:
parent
aeb6137d28
commit
1b0a89dc83
@ -201,12 +201,15 @@ function exec(script, stds) {
|
||||
else
|
||||
log_data = string.toString();
|
||||
|
||||
stds.std && stds.std.write && stds.std.write(log_data);
|
||||
stds.std && stds.std.write && stds.std.write(log_data, encoding);
|
||||
|
||||
// hardcoded values of special log path to not write on disk
|
||||
if (pm2_env.pm_err_log_path !== 'NULL' && pm2_env.pm_err_log_path !== '/dev/null') {
|
||||
stds.err.write && stds.err.write(log_data, encoding, cb);
|
||||
};
|
||||
if (pm2_env.pm_err_log_path !== 'NULL' && pm2_env.pm_err_log_path !== '/dev/null' && stds.err.write) {
|
||||
stds.err.write(log_data, encoding, cb);
|
||||
}
|
||||
else if (cb) {
|
||||
cb();
|
||||
}
|
||||
|
||||
process.send({
|
||||
type : 'log:err',
|
||||
@ -235,11 +238,14 @@ function exec(script, stds) {
|
||||
else
|
||||
log_data = string.toString();
|
||||
|
||||
stds.std && stds.std.write && stds.std.write(log_data);
|
||||
stds.std && stds.std.write && stds.std.write(log_data, encoding);
|
||||
|
||||
// hardcoded values of special log path to not write on disk
|
||||
if (pm2_env.pm_out_log_path !== 'NULL' && pm2_env.pm_out_log_path !== '/dev/null') {
|
||||
stds.out.write && stds.out.write(log_data);
|
||||
if (pm2_env.pm_out_log_path !== 'NULL' && pm2_env.pm_out_log_path !== '/dev/null' && stds.out.write) {
|
||||
stds.out.write(log_data, encoding, cb);
|
||||
}
|
||||
else if (cb) {
|
||||
cb();
|
||||
}
|
||||
|
||||
process.send({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user