Answer the question
In order to leave comments, you need to log in
Would such a Node.js daemon structure be correct?
As a practical warm-up while learning Node.js, I decided to try rewriting my data handler.
Now implemented in php: by cron, one script receives a list of tasks from the database and runs another php script (hundreds) in the background to complete the task (the task consists of obtaining data via http from hundreds of sources, JSON processing, calculations and folding into the database and files) . I do not like a huge number of processes, well, in terms of memory consumption, IMHO should feel better.
Unfortunately, all examples on the Internet implement a web application / server. I must have a daemon/client. Well, maybe some kind of web muzzle for viewing statistics / downloads, but that's later.
Schematically, I have this:
var connection = mysql.createConnection(...); // ничего, что соединение одно? в job.start его можно использовать?
var core = setInterval(function() {
connection.query('SELECT job FROM jobs', {}, function(err, res){ // получить работу
res.forEach(function(job){
job.start(); // собственно работа
});
});
}, 60000); //раз в минуту получить задания
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question