L
L
livemirsi2016-06-03 10:47:45
Node.js
livemirsi, 2016-06-03 10:47:45

Nodejs how to organize an application?

Good afternoon. I have a nodejs application. Not using as a server. The application works with databases, api for preparing information in the database for the main application. The application is daemonized with pm2.
There is a misunderstanding in the organization of global logic.
The application has modules, one for processing the database, the other for working with api, etc. I launch them through the main application file app.js there and plan to build all the logic (global, when to run it). So far they can’t figure out how to properly organize the logic, since you need to run the launched functions in turn, interrupt others while others are executing, I think to use an Eventemitter, if an event happens, it triggers this function, we interrupt the rest (it’s stupid to make a return in the modules of the function that is doing the work at the moment ) Can there be any other ways to organize this business?
Is it worth doing the functions that I launch in the form of chilprocces or can I run several functions in parallel for processing without it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
CodeKeeper, 2016-06-03
@CodeKeeper

Node.js already has a wonderful async library that already implements patterns such as - parallel, series, waterfall.
After reading the description of the patterns contained in the library, you can find the most suitable for the task.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question