mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-13 03:02:49 +00:00
updated package.json
This commit is contained in:
3
node_modules/ps-tree/.npmignore
generated
vendored
Normal file
3
node_modules/ps-tree/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
node_modules/*
|
||||
npm_debug.log
|
||||
49
node_modules/ps-tree/index.js
generated
vendored
Normal file
49
node_modules/ps-tree/index.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
var spawn = require('child_process').spawn,
|
||||
es = require('event-stream');
|
||||
|
||||
module.exports = childrenOfPid
|
||||
|
||||
function childrenOfPid( pid, callback) {
|
||||
var headers = null;
|
||||
|
||||
if('function' !== typeof callback)
|
||||
throw new Error('childrenOfPid(pid, callback) expects callback')
|
||||
if('number' == typeof pid)
|
||||
pid = pid.toString()
|
||||
|
||||
es.connect(
|
||||
spawn('ps', ['-A', '-o', 'ppid,pid']).stdout,
|
||||
es.split(),
|
||||
es.map(function (line, cb) { //this could parse alot of unix command output
|
||||
var columns = line.trim().split(/\s+/)
|
||||
if(!headers)
|
||||
headers = columns
|
||||
else {
|
||||
var row = {}
|
||||
//for each header,
|
||||
var h = headers.slice()
|
||||
while (h.length) {
|
||||
row[h.shift()] = h.length ? columns.shift() : columns.join(' ')
|
||||
}
|
||||
return cb(null, row)
|
||||
}
|
||||
return cb()
|
||||
}),
|
||||
es.writeArray(function (err, ps) {
|
||||
var parents = [pid], children = []
|
||||
ps.forEach(function (proc) {
|
||||
if(-1 != parents.indexOf(proc.PPID)) {
|
||||
parents.push(proc.PID)
|
||||
children.push(proc)
|
||||
}
|
||||
})
|
||||
callback(null, children)
|
||||
})
|
||||
).on('error', callback)
|
||||
}
|
||||
|
||||
if(!module.parent) {
|
||||
childrenOfPid(process.argv[2] || 1, function (err, data) {
|
||||
console.log(data)
|
||||
})
|
||||
}
|
||||
70
node_modules/ps-tree/package.json
generated
vendored
Normal file
70
node_modules/ps-tree/package.json
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"ps-tree@0.0.x",
|
||||
"/home/mywebsite/node_modules/forever-monitor"
|
||||
]
|
||||
],
|
||||
"_from": "ps-tree@>=0.0.0 <0.1.0",
|
||||
"_id": "ps-tree@0.0.3",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/ps-tree",
|
||||
"_npmUser": {
|
||||
"email": "charlie.robbins@gmail.com",
|
||||
"name": "indexzero"
|
||||
},
|
||||
"_npmVersion": "1.1.66",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "ps-tree",
|
||||
"raw": "ps-tree@0.0.x",
|
||||
"rawSpec": "0.0.x",
|
||||
"scope": null,
|
||||
"spec": ">=0.0.0 <0.1.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/forever-monitor"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/ps-tree/-/ps-tree-0.0.3.tgz",
|
||||
"_shasum": "dbf8d752a7fe22fa7d58635689499610e9276ddc",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "ps-tree@0.0.x",
|
||||
"_where": "/home/mywebsite/node_modules/forever-monitor",
|
||||
"author": {
|
||||
"name": "Charlie Robbins"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/indexzero/ps-tree/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"event-stream": "~0.5"
|
||||
},
|
||||
"description": "get all children of a pid",
|
||||
"devDependencies": {},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "dbf8d752a7fe22fa7d58635689499610e9276ddc",
|
||||
"tarball": "http://registry.npmjs.org/ps-tree/-/ps-tree-0.0.3.tgz"
|
||||
},
|
||||
"homepage": "http://github.com/indexzero/ps-tree",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "dominictarr",
|
||||
"email": "dominic.tarr@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "indexzero",
|
||||
"email": "charlie.robbins@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "ps-tree",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/indexzero/ps-tree.git"
|
||||
},
|
||||
"version": "0.0.3"
|
||||
}
|
||||
48
node_modules/ps-tree/readme.markdown
generated
vendored
Normal file
48
node_modules/ps-tree/readme.markdown
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
#ps-tree
|
||||
|
||||
sometimes you cannot kill child processes like you would expect,
|
||||
this a feature of UNIX.
|
||||
|
||||
>in UNIX, a process may terminate by using the exit call, and it's parent process may wait for that event by using the wait system call. the wait system call returns the process identifier of a terminated child, so that the parent tell which of the possibly many children has terminated. If the parent terminates, however, all it's children have assigned as their new parent the init process. Thus, the children still have a parent to collect their status and execution statistics.
|
||||
> (from "operating system concepts")
|
||||
|
||||
solution: use `ps-tree` to get all processes that a child_process may have started, so that they may all be terminated.
|
||||
|
||||
``` js
|
||||
var cp = require('child_process'),
|
||||
psTree = require('ps-tree')
|
||||
|
||||
var child = cp.exec("node -e 'while (true);'",function () {...})
|
||||
|
||||
child.kill() //this will not actually kill the child it will kill the `sh` process.
|
||||
|
||||
```
|
||||
|
||||
wtf? it's because exec actually works like this:
|
||||
|
||||
``` js
|
||||
function exec (cmd, cb) {
|
||||
spawn('sh', ['-c', cmd])
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
sh starts parses the command string and starts processes, and waits for them to terminate.
|
||||
but exec returns a process object with the pid of the sh process.
|
||||
but since it is in `wait` mode killing it does not kill the children.
|
||||
|
||||
used ps tree like this:
|
||||
|
||||
``` js
|
||||
|
||||
var cp = require('child_process'),
|
||||
psTree = require('ps-tree')
|
||||
|
||||
var child = cp.exec("node -e 'while (true);'",function () {...})
|
||||
|
||||
psTree(child.pid, function (err, children) {
|
||||
cp.spawn('kill', ['-9'].concat(children.map(function (p) {return p.PID})))
|
||||
})
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user