Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pfork

Package Overview
Dependencies
Maintainers
0
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pfork

fork process

  • 0.6.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6K
decreased by-17.22%
Maintainers
0
Weekly downloads
 
Created
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

Package last updated on 21 Jun 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc