run backup uploader with a nice of 15
the gzip takes a lot of cpu processing and hogs the CPU. With a nice level, we give other things higher priority. An alternate idea that was explored was to use cpulimit. This is to send SIGSTOP and SIGCONT periodically but this will not make use of the CPU if it's idle (unlike nice). Another idea is to use cgroups, but it's not clear how to use it with the dynamic setup we have. part of #691
This commit is contained in:
14
src/shell.js
14
src/shell.js
@@ -13,7 +13,8 @@ var assert = require('assert'),
|
||||
once = require('once'),
|
||||
util = require('util');
|
||||
|
||||
var SUDO = '/usr/bin/sudo';
|
||||
const SUDO = '/usr/bin/sudo';
|
||||
const NICE = '/usr/bin/nice';
|
||||
|
||||
function exec(tag, cmd, callback) {
|
||||
assert.strictEqual(typeof tag, 'string');
|
||||
@@ -39,11 +40,16 @@ function spawn(tag, file, args, options, callback) {
|
||||
|
||||
callback = once(callback); // exit may or may not be called after an 'error'
|
||||
|
||||
debug(tag + ' spawn: %s %s', file, args.join(' '));
|
||||
|
||||
if (options.ipc) options.stdio = ['pipe', 'pipe', 'pipe', 'ipc'];
|
||||
|
||||
var cp = child_process.spawn(file, args, options);
|
||||
if (options.nice) {
|
||||
args = ['-n', options.nice, file].concat(args);
|
||||
file = NICE;
|
||||
}
|
||||
|
||||
debug(tag + ' spawn: %s %s', file, args.join(' '));
|
||||
const cp = child_process.spawn(file, args, options);
|
||||
|
||||
if (options.logStream) {
|
||||
cp.stdout.pipe(options.logStream);
|
||||
cp.stderr.pipe(options.logStream);
|
||||
|
||||
Reference in New Issue
Block a user