From 0c2eb052ba007c24576f9b642ef72e6595368b75 Mon Sep 17 00:00:00 2001 From: arshiam2 <arshiam2@illinois.edu> Date: Sat, 1 Dec 2018 22:28:00 -0600 Subject: [PATCH] update --- cli/src/commands/get-second.js | 29 +++++++++++++++++++++++++++++ sfds/index.js | 6 ++++++ 2 files changed, 35 insertions(+) create mode 100644 cli/src/commands/get-second.js diff --git a/cli/src/commands/get-second.js b/cli/src/commands/get-second.js new file mode 100644 index 0000000..607fa53 --- /dev/null +++ b/cli/src/commands/get-second.js @@ -0,0 +1,29 @@ +// @flow +const path = require("path"); +const chalk = require("chalk"); +const fs = require("fs"); +const util = require("util"); +const net = require("net"); +const process = require("process"); +var request = require("request"); + +const handleErrors = require("../utils/handleErrors"); +const getMaster = require("../utils/getMaster"); + +module.exports.command = "get-second"; +module.exports.describe = "Writes the names of the latest numversions of sdfsfilename to a localfilename."; +module.exports.builder = (yargs: any) => yargs; + +module.exports.handler = handleErrors(async (argv: {}) => { + const master = await getMaster() + var target = "http://"+ master + ":3000/getSecond/"; + request.post(target, function(error, response, body) { + console.log(body.toString()) + // fs.writeFile(argv.localfilename, body.toString(), function(err) { + // if (err) console.log(err) + // console.log("Written to " + process.cwd() + "/" + argv.localfilename) + // process.exit(0) + // }); + // process.exit(0) + }) +}); diff --git a/sfds/index.js b/sfds/index.js index 539070d..07819f9 100644 --- a/sfds/index.js +++ b/sfds/index.js @@ -416,6 +416,12 @@ app.get("/sink", function(req, res) { } }); +app.post("/getSecond", function(req, res) { + // console.log("spout got: " + req.body.state); + // queue.push(req.body); + res.send("second"); +}); + round_robin = 0; setInterval(function sync() { -- GitLab