Node.js ကျူတိုရီရယ်

Node.js ပင်မစာမျက်နှာ Node.js နိဒါန်း Node.js ကို စတင်လိုက်ပါ။ Node.js မော်ဂျူးများ Node.js HTTP မော်ဂျူး Node.js ဖိုင်စနစ် Node.js URL မော်ဂျူး Node.js NPM Node.js ပွဲများ Node.js ဖိုင်များ အပ်လုဒ်လုပ်ခြင်း။ Node.js အီးမေးလ်

Node.js MySQL

MySQL စတင်လိုက်ပါ။ MySQL ဒေတာဘေ့စ်ဖန်တီးပါ။ MySQL ဇယားဖန်တီးပါ။ MySQL ထဲသို့ ထည့်သွင်းပါ။ MySQL မှ ရွေးချယ်ပါ။ MySQL ဘယ်မှာလဲ။ MySQL Order By MySQL ကိုဖျက်ပါ။ MySQL Drop Table MySQL အပ်ဒိတ် MySQL ကန့်သတ်ချက် MySQL Join

Node.js MongoDB

MongoDB စတင်လိုက်ပါ။ MongoDB ဒေတာဘေ့စ်ဖန်တီးပါ။ MongoDB သည် Collection ကိုဖန်တီးပါ။ MongoDB ထည့်သွင်းပါ။ MongoDB ကိုရှာပါ။ MongoDB မေးခွန်း MongoDB အမျိုးအစား MongoDB ကိုဖျက်ပါ။ MongoDB Drop Collection MongoDB အပ်ဒိတ် MongoDB ကန့်သတ်ချက် MongoDB Join

Raspberry Pi

RasPi စတင်လိုက်ပါ။ RasPi GPIO နိဒါန်း RasPi မှိတ်တုတ်မှိတ်တုတ် LED RasPi LED နှင့် ခလုတ်နှိပ်ပါ။ RasPi စီးဆင်းနေသော LED များ RasPi WebSocket RasPi RGB LED WebSocket RasPi အစိတ်အပိုင်းများ

Node.js အ ကိုး အကား

Built-in Modules များ

Node.js Cluster Process Module

❮ Built-in Modules


ဥပမာ

ကုဒ်ကို သုံးကြိမ် run ပါ၊ ပထမအကြိမ်သည် မာစတာအဖြစ်၊ ထို့နောက် အလုပ်သမားများအနေဖြင့်
var cluster = require('cluster');

if (cluster.isWorker) {
  console.log('I am a worker');
} else {
  console.log('I am a master');
  cluster.fork();
  cluster.fork();
}

အဓိပ္ပါယ်နှင့် အသုံးပြုမှု

အစုလိုက် မော်ဂျူးသည် တစ်ပြိုင်နက် လုပ်ဆောင်ပြီး တူညီသော ဆာဗာဆိပ်ကမ်းကို မျှဝေသည့် ကလေး လုပ်ငန်းစဉ်များကို ဖန်တီးသည့် နည်းလမ်းကို ပံ့ပိုးပေးပါသည်။

Node.js သည် မန်မိုရီအလွန်ထိရောက်သော single threaded programming ကိုလုပ်ဆောင်သည်၊ သို့သော် ကွန်ပျူတာများ၏ multi-core စနစ်များကို အခွင့်ကောင်းယူရန်၊ Cluster module သည် load ကိုကိုင်တွယ်ရန် ၎င်းတို့၏ကိုယ်ပိုင် thread တစ်ခုတည်းတွင် လုပ်ဆောင်သည့် ကလေးလုပ်ငန်းစဉ်များကို အလွယ်တကူဖန်တီးနိုင်စေမည်ဖြစ်သည်။


အထားအသို

သင့်အပလီကေးရှင်းရှိ အစုအစည်း module အပါအဝင် အထားအသို-

var cluster = require('cluster');

Cluster Properties နှင့် Methods

Method Description
disconnect() Disconnects all workers
exitedAfterDisconnect Returns true if a worker was exited after disconnect, or the kill method
fork() Creates a new worker, from a master
id A unique id for a worker
isConnected Returns true if the worker is connected to its master, otherwise false
isDead Returns true if the worker's process is dead, otherwise false
isMaster Returns true if the current process is master, otherwise false
isWorker Returns true if the current process is worker, otherwise false
kill() Kills the current worker
process Returns the global Child Process
schedulingPolicy Sets or gets the schedulingPolicy
send() sends a message to a master or a worker
settings Returns an object containing the cluster's settings
setupMaster() Changes the settings of a cluster
worker Returns the current worker object
workers Returns all workers of a master

❮ Built-in Modules