mirror of
https://github.com/soconnor0919/beenpad.git
synced 2026-02-05 00:06:40 -05:00
first commit
This commit is contained in:
1
node_modules/why-is-node-running/.github/FUNDING.yml
generated
vendored
Normal file
1
node_modules/why-is-node-running/.github/FUNDING.yml
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
github: mafintosh
|
||||
21
node_modules/why-is-node-running/LICENSE
generated
vendored
Normal file
21
node_modules/why-is-node-running/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Mathias Buus
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
104
node_modules/why-is-node-running/README.md
generated
vendored
Normal file
104
node_modules/why-is-node-running/README.md
generated
vendored
Normal file
@@ -0,0 +1,104 @@
|
||||
# why-is-node-running
|
||||
|
||||
Node is running but you don't know why? `why-is-node-running` is here to help you.
|
||||
|
||||
## Installation
|
||||
|
||||
Node 8 and above:
|
||||
|
||||
```bash
|
||||
npm i why-is-node-running -g
|
||||
```
|
||||
|
||||
Earlier Node versions (no longer supported):
|
||||
|
||||
```bash
|
||||
npm i why-is-node-running@v1.x -g
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const log = require('why-is-node-running') // should be your first require
|
||||
const net = require('net')
|
||||
|
||||
function createServer () {
|
||||
const server = net.createServer()
|
||||
setInterval(function () {}, 1000)
|
||||
server.listen(0)
|
||||
}
|
||||
|
||||
createServer()
|
||||
createServer()
|
||||
|
||||
setTimeout(function () {
|
||||
log() // logs out active handles that are keeping node running
|
||||
}, 100)
|
||||
```
|
||||
|
||||
Save the file as `example.js`, then execute:
|
||||
|
||||
```bash
|
||||
node ./example.js
|
||||
```
|
||||
|
||||
Here's the output:
|
||||
|
||||
```
|
||||
There are 5 handle(s) keeping the process running
|
||||
|
||||
# Timeout
|
||||
/home/maf/dev/node_modules/why-is-node-running/example.js:6 - setInterval(function () {}, 1000)
|
||||
/home/maf/dev/node_modules/why-is-node-running/example.js:10 - createServer()
|
||||
|
||||
# TCPSERVERWRAP
|
||||
/home/maf/dev/node_modules/why-is-node-running/example.js:7 - server.listen(0)
|
||||
/home/maf/dev/node_modules/why-is-node-running/example.js:10 - createServer()
|
||||
|
||||
# Timeout
|
||||
/home/maf/dev/node_modules/why-is-node-running/example.js:6 - setInterval(function () {}, 1000)
|
||||
/home/maf/dev/node_modules/why-is-node-running/example.js:11 - createServer()
|
||||
|
||||
# TCPSERVERWRAP
|
||||
/home/maf/dev/node_modules/why-is-node-running/example.js:7 - server.listen(0)
|
||||
/home/maf/dev/node_modules/why-is-node-running/example.js:11 - createServer()
|
||||
|
||||
# Timeout
|
||||
/home/maf/dev/node_modules/why-is-node-running/example.js:13 - setTimeout(function () {
|
||||
```
|
||||
|
||||
**Important Note!**
|
||||
`unref`ed timers do not prevent the Node process from exiting. If you are running with Node v11.0.0 and above, `unref`ed timers will not be listed in the above list. Unfortunately, this is not supported in node versions below v11.0.0.
|
||||
|
||||
## CLI
|
||||
|
||||
You can also run `why-is-node-running` as a standalone if you don't want to include it inside your code. Sending `SIGUSR1`/`SIGINFO` signal to the process will produce the log. (`Ctrl + T` on macOS and BSD systems)
|
||||
|
||||
```bash
|
||||
why-is-node-running /path/to/some/file.js
|
||||
```
|
||||
|
||||
```
|
||||
probing module /path/to/some/file.js
|
||||
kill -SIGUSR1 31115 for logging
|
||||
```
|
||||
|
||||
To trigger the log:
|
||||
|
||||
```
|
||||
kill -SIGUSR1 31115
|
||||
```
|
||||
|
||||
## Require CLI Option
|
||||
|
||||
You can also use the node `-r` option to include `why-is-node-running`:
|
||||
|
||||
```bash
|
||||
node -r why-is-node-running/include /path/to/some/file.js
|
||||
```
|
||||
|
||||
The steps are otherwise the same as the above CLI section
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
18
node_modules/why-is-node-running/cli.js
generated
vendored
Executable file
18
node_modules/why-is-node-running/cli.js
generated
vendored
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var spawn = require('child_process').spawn
|
||||
var path = require('path')
|
||||
|
||||
var prog = path.resolve(process.argv[2])
|
||||
var progArgs = process.argv.slice(3)
|
||||
|
||||
console.log('probing program', prog)
|
||||
|
||||
var nodeArgs = [
|
||||
'-r',
|
||||
path.join(__dirname, 'include.js')
|
||||
]
|
||||
var nodeOpts = { stdio: 'inherit' }
|
||||
var child = spawn('node', nodeArgs.concat(prog).concat(progArgs), nodeOpts)
|
||||
|
||||
console.log('kill -SIGUSR1', child.pid, 'for logging')
|
||||
15
node_modules/why-is-node-running/example.js
generated
vendored
Normal file
15
node_modules/why-is-node-running/example.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
var log = require('./')
|
||||
var net = require('net')
|
||||
|
||||
function createServer () {
|
||||
var server = net.createServer()
|
||||
setInterval(function () {}, 1000)
|
||||
server.listen(0)
|
||||
}
|
||||
|
||||
createServer()
|
||||
createServer()
|
||||
|
||||
setTimeout(function () {
|
||||
log()
|
||||
}, 100)
|
||||
3
node_modules/why-is-node-running/include.js
generated
vendored
Normal file
3
node_modules/why-is-node-running/include.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
var why = require('./')
|
||||
|
||||
require('siginfo')(why, true)
|
||||
67
node_modules/why-is-node-running/index.js
generated
vendored
Normal file
67
node_modules/why-is-node-running/index.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
var asyncHooks = require('async_hooks')
|
||||
var stackback = require('stackback')
|
||||
var path = require('path')
|
||||
var fs = require('fs')
|
||||
var sep = path.sep
|
||||
|
||||
var active = new Map()
|
||||
var hook = asyncHooks.createHook({
|
||||
init (asyncId, type, triggerAsyncId, resource) {
|
||||
if (type === 'TIMERWRAP' || type === 'PROMISE') return
|
||||
if (type === 'PerformanceObserver' || type === 'RANDOMBYTESREQUEST') return
|
||||
var err = new Error('whatevs')
|
||||
var stacks = stackback(err)
|
||||
active.set(asyncId, {type, stacks, resource})
|
||||
},
|
||||
destroy (asyncId) {
|
||||
active.delete(asyncId)
|
||||
}
|
||||
})
|
||||
|
||||
hook.enable()
|
||||
module.exports = whyIsNodeRunning
|
||||
|
||||
function whyIsNodeRunning (logger) {
|
||||
if (!logger) logger = console
|
||||
|
||||
hook.disable()
|
||||
var activeResources = [...active.values()].filter(function(r) {
|
||||
if (
|
||||
typeof r.resource.hasRef === 'function'
|
||||
&& !r.resource.hasRef()
|
||||
) return false
|
||||
return true
|
||||
})
|
||||
|
||||
logger.error('There are %d handle(s) keeping the process running', activeResources.length)
|
||||
for (const o of activeResources) printStacks(o)
|
||||
|
||||
function printStacks (o) {
|
||||
var stacks = o.stacks.slice(1).filter(function (s) {
|
||||
var filename = s.getFileName()
|
||||
return filename && filename.indexOf(sep) > -1 && filename.indexOf('internal' + sep) !== 0 && filename.indexOf('node:internal' + sep) !== 0
|
||||
})
|
||||
|
||||
logger.error('')
|
||||
logger.error('# %s', o.type)
|
||||
|
||||
if (!stacks[0]) {
|
||||
logger.error('(unknown stack trace)')
|
||||
} else {
|
||||
var padding = ''
|
||||
stacks.forEach(function (s) {
|
||||
var pad = (s.getFileName() + ':' + s.getLineNumber()).replace(/./g, ' ')
|
||||
if (pad.length > padding.length) padding = pad
|
||||
})
|
||||
stacks.forEach(function (s) {
|
||||
var prefix = s.getFileName() + ':' + s.getLineNumber()
|
||||
try {
|
||||
var src = fs.readFileSync(s.getFileName(), 'utf-8').split(/\n|\r\n/)
|
||||
logger.error(prefix + padding.slice(prefix.length) + ' - ' + src[s.getLineNumber() - 1].trim())
|
||||
} catch (e) {
|
||||
logger.error(prefix + padding.slice(prefix.length))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
39
node_modules/why-is-node-running/package.json
generated
vendored
Normal file
39
node_modules/why-is-node-running/package.json
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "why-is-node-running",
|
||||
"version": "2.3.0",
|
||||
"description": "Node is running but you don't know why? why-is-node-running is here to help you.",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"siginfo": "^2.0.0",
|
||||
"stackback": "0.0.2"
|
||||
},
|
||||
"bin": {
|
||||
"why-is-node-running": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mafintosh/why-is-node-running.git"
|
||||
},
|
||||
"keywords": [
|
||||
"debug",
|
||||
"devops",
|
||||
"test",
|
||||
"events",
|
||||
"handles"
|
||||
],
|
||||
"author": "Mathias Buus (@mafintosh)",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Jon Peck",
|
||||
"email": "jpeck@fluxsauce.com"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/mafintosh/why-is-node-running/issues"
|
||||
},
|
||||
"homepage": "https://github.com/mafintosh/why-is-node-running"
|
||||
}
|
||||
Reference in New Issue
Block a user