[node] multiprocessing and runs continuously
TRANSCRIPT
![Page 1: [Node] Multiprocessing and runs continuously](https://reader033.vdocuments.site/reader033/viewer/2022042614/55a5c89f1a28abd7308b4651/html5/thumbnails/1.jpg)
Multiprocessing andruns continuously
2011-11-19kumatch / Yosuke Kumakura
11年11月19日土曜日
![Page 2: [Node] Multiprocessing and runs continuously](https://reader033.vdocuments.site/reader033/viewer/2022042614/55a5c89f1a28abd7308b4651/html5/thumbnails/2.jpg)
• Yosuke Kumakura
• @kumatch
• Feedtailor inc.
11年11月19日土曜日
![Page 3: [Node] Multiprocessing and runs continuously](https://reader033.vdocuments.site/reader033/viewer/2022042614/55a5c89f1a28abd7308b4651/html5/thumbnails/3.jpg)
Agenda
• Multiprocessing
• Continue to run a script
11年11月19日土曜日
![Page 4: [Node] Multiprocessing and runs continuously](https://reader033.vdocuments.site/reader033/viewer/2022042614/55a5c89f1a28abd7308b4651/html5/thumbnails/4.jpg)
Today’s modules
• Cluster (for Node 0.6)
• forever
11年11月19日土曜日
![Page 5: [Node] Multiprocessing and runs continuously](https://reader033.vdocuments.site/reader033/viewer/2022042614/55a5c89f1a28abd7308b4651/html5/thumbnails/5.jpg)
Cluster
• Includes version 0.5.10
• committed on Oct. 12, 2011
• adds CLI option first.
• Shift to module (Oct. 27, 2011)
• removed CLI option.
• Bump v 0.6.0 (Nov. 4, 2011)
11年11月19日土曜日
![Page 6: [Node] Multiprocessing and runs continuously](https://reader033.vdocuments.site/reader033/viewer/2022042614/55a5c89f1a28abd7308b4651/html5/thumbnails/6.jpg)
Master process
Workerprocess
Workerprocess
Networkports
11年11月19日土曜日
![Page 7: [Node] Multiprocessing and runs continuously](https://reader033.vdocuments.site/reader033/viewer/2022042614/55a5c89f1a28abd7308b4651/html5/thumbnails/7.jpg)
Cluster APIs
• fork()
• isMaster
• isWorker
• “death” event for worker die
11年11月19日土曜日
![Page 8: [Node] Multiprocessing and runs continuously](https://reader033.vdocuments.site/reader033/viewer/2022042614/55a5c89f1a28abd7308b4651/html5/thumbnails/8.jpg)
Cluster usage
• cluster.isMaster
• cluster.fork()
• cluster.isWorker
• ex. http.Server()
11年11月19日土曜日
![Page 9: [Node] Multiprocessing and runs continuously](https://reader033.vdocuments.site/reader033/viewer/2022042614/55a5c89f1a28abd7308b4651/html5/thumbnails/9.jpg)
Cluster usage
• Cluster worker is Child Process
• using child_process.fork()
• Built-in messaging channel
11年11月19日土曜日
![Page 10: [Node] Multiprocessing and runs continuously](https://reader033.vdocuments.site/reader033/viewer/2022042614/55a5c89f1a28abd7308b4651/html5/thumbnails/10.jpg)
Cluster for Node 0.4
• http://learnboost.github.com/cluster/
11年11月19日土曜日
![Page 11: [Node] Multiprocessing and runs continuously](https://reader033.vdocuments.site/reader033/viewer/2022042614/55a5c89f1a28abd7308b4651/html5/thumbnails/11.jpg)
forever
• https://github.com/nodejitsu/forever
• Run a script as a daemon
• CLI tool (and module instance)
11年11月19日土曜日
![Page 12: [Node] Multiprocessing and runs continuously](https://reader033.vdocuments.site/reader033/viewer/2022042614/55a5c89f1a28abd7308b4651/html5/thumbnails/12.jpg)
$ [sudo] npm install -g forever
$ forever start app.js
11年11月19日土曜日
![Page 13: [Node] Multiprocessing and runs continuously](https://reader033.vdocuments.site/reader033/viewer/2022042614/55a5c89f1a28abd7308b4651/html5/thumbnails/13.jpg)
forever daemon actions
• start
• stop
• restart
• list
• and more...
11年11月19日土曜日
![Page 14: [Node] Multiprocessing and runs continuously](https://reader033.vdocuments.site/reader033/viewer/2022042614/55a5c89f1a28abd7308b4651/html5/thumbnails/14.jpg)
Node 0.6 + forever 0.7.2 = unstoppable !!!
• start is available
• list, stop and etc. don’t work
11年11月19日土曜日