why-is-node-running

Node is running but you don't know why? why-is-node-running is here to help you.

  • 所有者: mafintosh/why-is-node-running
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

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:

npm i why-is-node-running -g

Earlier Node versions (no longer supported):

npm i why-is-node-running@v1.x -g

Usage

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:

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 () {

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 signal to the process will produce the log.

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

License

MIT

主要指標

概覽
名稱與所有者mafintosh/why-is-node-running
主編程語言JavaScript
編程語言JavaScript (語言數: 1)
平台
許可證MIT License
所有者活动
創建於2016-02-09 15:29:28
推送於2025-01-08 15:01:13
最后一次提交2025-01-08 16:00:59
發布數24
最新版本名稱v3.2.2 (發布於 2025-01-08 16:01:02)
第一版名稱v1.0.0 (發布於 2016-02-09 16:29:25)
用户参与
星數1.9k
關注者數18
派生數46
提交數72
已啟用問題?
問題數42
打開的問題數9
拉請求數35
打開的拉請求數0
關閉的拉請求數10
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?