Git Product home page Git Product logo

node-process-pool's People

Contributors

geniusfunny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

node-process-pool's Issues

任务完成进程没有结束

代码大概是这样的

**const processPool = new ProcessPool({
maxParallelProcess: 50, // 支持最大进程并行数
timeToClose: 10 * 1000, // 单个任务被执行最大时长
dependency: const path = require('path'); var lib=require("./lib");var execSync = require('child_process').execSync;var config = require('./config');, // 任务脚本依赖
workDir: __dirname, // 当前目录
taskName: 'doTwitter', // 任务脚本名称
script: async function task(workParam) {
val = workParam;

    cmd = `twint -u '${val}' --since '${today} 00:00:00' ${proxy} -o ./data/${val}_${today}.json --json`;
    // console.log(cmd);
    execSync(cmd,{timeout:8000});
}, // 任务脚本内容
taskParams // 需要执行的任务参数列表,二维数组

});
// 创建进程池实例
// 利用进程池进行处理大规模任务
processPool.run();**

跑完了 脚本没退出

文件依赖、路径参数、模块设计存在严重问题

由于目前将task函数直接赋值给进程池示例的script属性,且在进程池示例中将script写入task.js,这也存在很大的问题。

  1. 如果task函数存在模块依赖,依赖怎么注入到task.js
  2. 如果是相对路径,怎么解决路径参数的问题
  3. 每次将script加入到task.js,这是修改模块!!!并且很冗余
  4. 重构!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.