Skip to content

Instantly share code, notes, and snippets.

View rvigneshw's full-sized avatar
😎
Experimenting.....!

Vigneshwaran R rvigneshw

😎
Experimenting.....!
View GitHub Profile
@rvigneshw
rvigneshw / Get back data from Child process worker.js
Created September 17, 2021 13:30
Get back data from Child process worker
worker.on('message', (processedData) => {
doSomethingElse(processedData);
worker.kill();
});
@rvigneshw
rvigneshw / Send the data.js
Created September 17, 2021 13:29
Send the data
worker.send(data);
@rvigneshw
rvigneshw / Invoke the Worker.js
Created September 17, 2021 13:27
Invoke the Worker
const worker = fork(filename.js)
@rvigneshw
rvigneshw / Child process code template.js
Created September 17, 2021 13:26
Child process code template
process.on('message', (payload) => {
try {
//Some time taking stuff
const processedData = processData(payload);
process.send(processedData);
} catch (error) {
process.send(error);
}
});
@rvigneshw
rvigneshw / Importing Fork from Child process module.js
Created September 17, 2021 13:25
Importing Fork from Child process module
const fork = require('child_process').fork;
@rvigneshw
rvigneshw / Block the Event loop of nodeJS.js
Last active September 17, 2021 13:25
Blocking the Event Loop of Node.js
let flag = false;
setTimeout(() => {
// this callback never gets called
// because event loop is blocked
flag = true;
}, 1000);
while (!flag) {
console.log("still waiting")
}
@rvigneshw
rvigneshw / docker-on-ubuntu.sh
Last active October 30, 2020 10:11
Single Script install of Docker on Ubuntu 20.04
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