ggs-cron/lib/zmq.js

28 lines
541 B
JavaScript
Raw Permalink Normal View History

const zmq = require('zeromq');
const uuid = require('uuid');
/**
* Publish simple message to server to notify service is ready.
*/
async function startup(){
const pub = new zmq.Publisher();
await pub.connect("tcp://127.0.0.1:36541");
const msg = {
id: uuid.v4(),
topic: "news",
message_type: "Data",
data: { content: "GGS Ready!" },
timestamp: Math.floor(Date.now() / 1000)
};
await pub.send(["news", JSON.stringify(msg)]);
console.log("startup send!")
pub.close();
}
module.exports = {
startup
};