9 Haziran 2020 Salı

Node.js

node Uygulaması
node uygulaması ile bir javascript dosyası çalıştırmak için Linux'ta şöyle yaparız
/usr/local/bin/node /home/somepath/example/script.js
Event Loop
Açıklaması şöyle
In a Node.js application, concurrency is handled by an Event Dispatcher called Event Loop (which is single threaded, and it has no race conditions or deadlock issues). Once the task is written via one of these asynchronous ways (Callbacks, Promises, or Async/await), the task will run asynchronously via Event Loop.
Event loop çalışma sırası şöyle.
1.Timers
2.Pending callbacks
3.Idle/Prepare
4.Poll
5.Check/setImmediate
6.Closing callbacks
Worker Thread
Açıklaması şöyle
The Node.js system only had a single thread when it was created. (It introduced worker threads in v10.5.0).

Node Schedule Paketi
cron gibi çalışır
Örnek
Şöyle yaparız
const j = schedule.scheduleJob('*/15 * * * *', () => {...});

Hiç yorum yok:

Yorum Gönder