- By Edmond Lau
- Highly Recommended 👍
- http://www.theeffectiveengineer.com/
- They are the people who get things done. Effective Engineers produce results.
const fs = require('fs') | |
fs.open('./index.js', 'r', (err, fd) => { | |
//Access fd here | |
if(err) return "error while open FD"; | |
fs.readFile(fd, function(err, msg) { | |
if(err) return "error while read file"; | |
console.log('msg===', msg.toString()) |
const cluster = require('cluster'); | |
const http = require('http'); | |
const numCPUs = require('os').cpus().length; | |
if (cluster.isMaster) { | |
console.log(`Master ${process.pid} is running`); | |
var worker_id = ''; | |
// Fork workers. | |
for (let i = 0; i < numCPUs; i++) { | |
worker_id = '900'+i; |
//https://www.npmjs.com/package/recluster | |
var recluster = require('recluster'), | |
path = require('path'); | |
var cluster = recluster(path.join(__dirname, 'server.js'),{workers : 2}); | |
cluster.run(); | |
process.on('SIGUSR2', function() { | |
console.log('Got SIGUSR2, reloading cluster...'); |
//https://www.npmjs.com/package/recluster | |
var recluster = require('recluster'), | |
path = require('path'); | |
var cluster = recluster(path.join(__dirname, 'server.js'),{workers : 2}); | |
cluster.run(); | |
process.on('SIGUSR2', function() { | |
console.log('Got SIGUSR2, reloading cluster...'); |
var http = require('http'); | |
var cluster = require('cluster'); | |
// The master's job to spawn workers initially and when they die | |
if (cluster.isMaster) { | |
// Get the number of processor cores | |
var cpuCount = require('os').cpus().length; | |
// Create a worker for each CPU | |
for (var i = 0; i < cpuCount; i += 1) { | |
cluster.fork(); |
let validator = { | |
set: function name(Obj, param, value) { | |
if(param === 'age'){ | |
if(! Number.isInteger(value)) throw new Error("age is not an number type") | |
if( !(value > 18 && value < 80)){ | |
throw Error("age range error, age must between 18 to 80 "); | |
} | |
} |
var svgWidth = 800; | |
var svgHeight = 300; | |
var margin = {top: 30, right: 40, bottom: 50, left: 60}; | |
var width = svgWidth - margin.left - margin.right; | |
var height = svgHeight - margin.top - margin.bottom; | |
var originalCircle = {"cx" : -150 , | |
"cy" : -15 , |
-- phpMyAdmin SQL Dump | |
-- version 4.0.9 | |
-- http://www.phpmyadmin.net | |
-- | |
-- Inang: localhost | |
-- Waktu pembuatan: 02 Mei 2014 pada 12.05 | |
-- Versi Server: 5.5.34 | |
-- mysql -u username -p database_name < file.sql | |
--create table customer ( |
module.exports.eventLoopblocked = function(func, opts){ | |
var option = opts | {}; | |
var threshold = opts.threshold | 10; | |
var interval = opts.threshold | 100; | |
var startTime= process.hrtime(); | |
var delta; | |
var timer = setInterval(function(){ | |