This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker.on('message', (processedData) => { | |
doSomethingElse(processedData); | |
worker.kill(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker.send(data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const worker = fork(filename.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
process.on('message', (payload) => { | |
try { | |
//Some time taking stuff | |
const processedData = processData(payload); | |
process.send(processedData); | |
} catch (error) { | |
process.send(error); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fork = require('child_process').fork; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let flag = false; | |
setTimeout(() => { | |
// this callback never gets called | |
// because event loop is blocked | |
flag = true; | |
}, 1000); | |
while (!flag) { | |
console.log("still waiting") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "Removing Docker IF EXISTS" | |
sudo apt-get remove docker docker-engine docker.io containerd runc | |
echo "Getting Docker install Script" | |
curl -fsSL https://get.docker.com -o get-docker.sh | |
echo "Executing Docker install Script" | |
sudo sh get-docker.sh | |
echo "Getting Docker-compose" | |
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose |