totaljs / framework

Node.js framework
http://www.totaljs.com
Other
4.36k stars 450 forks source link

Bug, F.worker not working on 3.2.4 #708

Closed namnguyen279 closed 5 years ago

namnguyen279 commented 5 years ago

It seem that F.worker does not execute workers even one with a simple console.log on current 3.2.4

petersirka commented 5 years ago

Hi @traubo279, F.worker() returns executes only one instance of worker and it returns child_process object. If you want to execute multiple same workers then you need to use WORKER2().

namnguyen279 commented 5 years ago

Hi @traubo279, F.worker() returns executes only one instance of worker and it returns child_process object. If you want to execute multiple same workers then you need to use WORKER2().

Hi @petersirka, in my case, both F.worker and F.worker2 do return the child_process object but don't execute anything inside the source worker file on version 3.2.4, i tried reinstall from npm and it doesnt work. Finally i reversed to 3.1.0 and it work. Node version tested on 8.9.1 and 11.5.0.

petersirka commented 5 years ago

Can you send me two examples with v3.2.4 and v3.1.0? I'll test it.

namnguyen279 commented 5 years ago

Here is my code in folder definitions/cron.js

function repeat () {
    let cc = F.worker("a", "worker")
    console.log("worker should be executed");
}
setInterval(repeat, 5000);
F.once('load', repeat);

and a simple in folder workers/a.js with console.log('message from worker') Output on 3.1.0:

Screen Shot 2019-05-31 at 1 18 42 PM

Output on 3.2.4:

Screen Shot 2019-05-31 at 1 16 53 PM
petersirka commented 5 years ago

Hi. I have changed behaviour for workers. Each worker has been executed in silent mode. But I have updated core of Total.js:

I'm not sure if this new behaviour is OK but it's better.

namnguyen279 commented 5 years ago

Hi @petersirka, it seem to work fine if allow_workers_silent is not exist or missing from the config file. Manually set it to false will result the same as set it to true in the config file.

petersirka commented 5 years ago

Hi @traubo279 , by default is false ... I have tested it and it works correctly. For F.worker2() is set to true (this can't be changed) because the reason is pipe between app and child process and worker2 executes a callback with the response from the stdout stream.

namnguyen279 commented 5 years ago

@petersirka, yes i know it working on default, but when i have"allow_workers_silent : false" in config, it's the same as "allow_workers_silent : true", which is may be miss leading to some people .. ;)

petersirka commented 5 years ago

True, I have fixed it. Thank you. New beta will be released next week.