简体   繁体   中英

nodejs multiple worker web api

I have seen the potential of NodeJS recently and try this for a small task to use .

about the following: i want to create a web service , which allows you to start and stop multiple client instances (multiple nodejs tasks who should run, until i send a stop request to a instance):

so a http server modul waits for start/stop requests (with params) (maybe with express?) like

[start] http://taskservice/start?user=abc&pass=123

the service should create a instance of a task like:

var task = new MyTask();
task.login(user, pass);

task.on("loginsuccess", function() {
  task.startwork();
};

[stop identified by user] http://taskservice/stop?user=abc

The problem is, I do not know how this can be best implemented . It must always be able to create any number of tasks and the tasks must run until I say stop . (the tasks require very little performance)

Does anyone have an idea or a small code example ?

I am not sure if this is the proper way to do it but I think you can do it with forever. Check this link; http://www.codingdefined.com/2014/08/use-of-forever-in-nodejs.html

You can stop and start child nodejs processes through your root script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM