Socket
Socket
Sign inDemoInstall

pfork

Package Overview
Dependencies
1
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    pfork

fork process


Version published
Weekly downloads
2.8K
decreased by-8.64%
Maintainers
1
Install size
133 kB
Created
Weekly downloads
 

Readme

Source

pfork

用于在后台运行程序中启动一个进程执行相应的脚本

Installation

npm install pfork --save

Usage

var p = require('pfork');
var options = {
	script: '/User/xxx/test/script.js', //必填
	value: '/User/xxx/test/server.js',  //可选
	//其它字段
};
//会根据script和value自动去重
p.fork(options, function(err, data, child) {
	//启动结束
	//child.on('data', function(data) {});
	//child.sendData(data);
	//child.on('exit', function() {}); //退出的时候
});

/User/xxx/test/script.js

//options与fork的options字段一致
module.exports = function(options, callback) {
	//do sth
	// process.sendData(data);
	callback(err, data);
};

kill process:

p.kill({
	script: '/User/xxx/test/script.js',
	value: '/User/xxx/test/server.js'
});

判断进程是否已存在:

p.exists({
	script: '/User/xxx/test/script.js',
	value: '/User/xxx/test/server.js'
});

Keywords

FAQs

Last updated on 03 Apr 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc