Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to communicate between nodejs applications

// article on medium about this
// below are 2 independent running nodejs applications, which communicate using IPC

// process1.js
// This Process starts the pub-sub server, which other processes can connect to.
const ipc = require('node-ipc');

ipc.config.id = 'a-unique-process-name1';
ipc.config.retry = 1500;
ipc.config.silent = true;
ipc.serve(() => ipc.server.on('a-unique-message-name', message => {
  console.log(message);
}));
ipc.server.start();

// process2.js
const ipc = require('node-ipc');

ipc.config.id = 'a-unique-process-name2';
ipc.config.retry = 1500;
ipc.config.silent = true;
ipc.connectTo('a-unique-process-name1', () => {
  ipc.of['jest-observer'].on('connect', () => {
    ipc.of['jest-observer'].emit('a-unique-message-name', "The message we send");
  });
});

Comment

PREVIOUS NEXT
Code Example
Javascript :: get the first word from a string jquery 
Javascript :: javascript enumerate 
Javascript :: float js precision 
Javascript :: - Root composer.json requires tymon/jwt-auth ^0.5.12 - satisfiable by tymon/jwt-auth[0.5.12]. 
Javascript :: get parent element javascript 
Javascript :: js remove end comma 
Javascript :: how to make a if loop happen one 
Javascript :: get how much i scroll in jquery 
Javascript :: js does forEach respect order 
Javascript :: matomo error tracking 
Javascript :: react making post request 
Javascript :: array notation in javascript 
Javascript :: push elements to an object 
Javascript :: remove all chars from string and leave only numbers javascript 
Javascript :: javascript match number 
Javascript :: js check if number is divisible by 2 
Javascript :: jquery if div is empty 
Javascript :: js remove test character from string 
Javascript :: autofocus react 
Javascript :: call function after 2 seconds javascript 
Javascript :: jquery get 
Javascript :: hide / show jquery 
Javascript :: empty the value of an input in jquery 
Javascript :: maximum product of word 
Javascript :: add comma to number in javascript 
Javascript :: object loop in javascript 
Javascript :: how to print a number with commas as thousands separators in javascript 
Javascript :: array traversal backward 
Javascript :: how to remove element from array react native 
Javascript :: graphql disable cache 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =