@pixlcore/xyrun 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/main.js +13 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**xyOps Remote Job Runner (xyRun)** is a companion to the [xyOps](https://xyops.io) workflow automation and server monitoring platform. It is a wrapper for running remote jobs inside Docker containers, or over a remote SSH connection.
|
|
4
4
|
|
|
5
|
-
The idea is that when a job is running "remotely" (i.e. not a direct child process of [xySat](https://github.com/pixlcore/xysat)) then we cannot monitor system resources for the job. Also, input and output files simply do not work in these cases (because xySat expects them to be on the local filesystem where it is running). xyRun handles all these
|
|
5
|
+
The idea is that when a job is running "remotely" (i.e. not a direct child process of [xySat](https://github.com/pixlcore/xysat)) then we cannot monitor system resources for the job. Also, input and output files simply do not work in these cases (because xySat expects them to be on the local filesystem where it is running). xyRun handles all these complexities for you by sitting "in between" your job and xySat. xyRun should run *inside* the container or on the far end of the SSH connection, where your job process is running.
|
|
6
6
|
|
|
7
7
|
To use xyRun in a xyOps Event Plugin, make sure you set the Plugin's `runner` property to `true`. This hint tells xyOps (and ultimately xySat) that the job is running remotely out if its reach, and it should not perform the usual process and network monitoring, and file management. Those duties get delegated to xyRun.
|
|
8
8
|
|
package/main.js
CHANGED
|
@@ -12,7 +12,11 @@ const JSONStream = require('pixl-json-stream');
|
|
|
12
12
|
const PixlRequest = require('pixl-request');
|
|
13
13
|
const Tools = require('pixl-tools');
|
|
14
14
|
const pkg = require('./package.json');
|
|
15
|
+
|
|
15
16
|
const noop = function() {};
|
|
17
|
+
const async = Tools.async;
|
|
18
|
+
|
|
19
|
+
process.title = "xyRun";
|
|
16
20
|
|
|
17
21
|
const app = {
|
|
18
22
|
|
|
@@ -434,9 +438,6 @@ const app = {
|
|
|
434
438
|
|
|
435
439
|
if (!file.path) return; // sanity
|
|
436
440
|
|
|
437
|
-
// prepend job cwd if path is not absolute
|
|
438
|
-
if (!Path.isAbsolute(file.path)) file.path = Path.join(job.cwd, file.path);
|
|
439
|
-
|
|
440
441
|
if (file.filename) {
|
|
441
442
|
// if user specified a custom filename, then do not perform a glob
|
|
442
443
|
to_upload.push(file);
|
|
@@ -461,7 +462,7 @@ const app = {
|
|
|
461
462
|
// upload all job files (from user) if applicable
|
|
462
463
|
var self = this;
|
|
463
464
|
var final_files = [];
|
|
464
|
-
|
|
465
|
+
|
|
465
466
|
if (!job.files || !job.files.length || !Tools.isaArray(job.files)) return callback();
|
|
466
467
|
|
|
467
468
|
async.eachSeries( job.files,
|
|
@@ -501,7 +502,7 @@ const app = {
|
|
|
501
502
|
filename: filename,
|
|
502
503
|
path: json.key,
|
|
503
504
|
size: json.size,
|
|
504
|
-
server:
|
|
505
|
+
server: job.server,
|
|
505
506
|
job: job.id
|
|
506
507
|
});
|
|
507
508
|
|
|
@@ -565,8 +566,8 @@ const app = {
|
|
|
565
566
|
return;
|
|
566
567
|
}
|
|
567
568
|
|
|
568
|
-
// update job data
|
|
569
|
-
console.log( JSON.stringify({ xy: 1, procs: job.procs, conns: job.conns, cpu: job.cpu, mem: job.mem }) );
|
|
569
|
+
// update job data with stats in tow
|
|
570
|
+
console.log( JSON.stringify({ xy: 1, rpid: process.pid, procs: job.procs, conns: job.conns, cpu: job.cpu, mem: job.mem }) );
|
|
570
571
|
|
|
571
572
|
self.jobTickInProgress = false;
|
|
572
573
|
}
|
|
@@ -577,20 +578,21 @@ const app = {
|
|
|
577
578
|
measureJobResources(job, pids) {
|
|
578
579
|
// scan process list for all processes that are descendents of job pid
|
|
579
580
|
delete job.procs;
|
|
581
|
+
var root_pid = process.pid;
|
|
580
582
|
|
|
581
|
-
if (pids[
|
|
583
|
+
if (pids[ root_pid ]) {
|
|
582
584
|
// add all procs into job
|
|
583
585
|
job.procs = {};
|
|
584
|
-
job.procs[
|
|
586
|
+
job.procs[ root_pid ] = pids[ root_pid ];
|
|
585
587
|
|
|
586
|
-
var info = pids[
|
|
588
|
+
var info = pids[ root_pid ];
|
|
587
589
|
var cpu = info.cpu;
|
|
588
590
|
var mem = info.memRss;
|
|
589
591
|
|
|
590
592
|
// also consider children of the child (up to 100 generations deep)
|
|
591
593
|
var levels = 0;
|
|
592
594
|
var family = {};
|
|
593
|
-
family[
|
|
595
|
+
family[ root_pid ] = 1;
|
|
594
596
|
|
|
595
597
|
while (Tools.numKeys(family) && (++levels <= 100)) {
|
|
596
598
|
for (var fpid in family) {
|