Skip to content

Commit f37c6b9

Browse files
committed
Add support to REDIS_URL
1 parent 619d6a5 commit f37c6b9

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

bin/hflow

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
#!/usr/bin/env node
2+
3+
var redisURL = process.env.REDIS_URL ? {url: process.env.REDIS_URL} : {};
4+
5+
26
var docopt = require('docopt').docopt,
37
spawn = require('child_process').spawn,
4-
fs = require('fs'),
8+
fs = require('fs'),
59
pathtool = require('path'),
610
redis = require('redis'),
7-
rcl = redis.createClient(),
11+
rcl = redis.createClient(redisURL),
812
wflib = require('../wflib').init(rcl),
913
Engine = require('../engine2'),
1014
async = require('async'),
@@ -42,15 +46,15 @@ function hflow_run() {
4246
if (opts['--with-server']) {
4347
hflow_start(); // start the HTTP server
4448
}
45-
49+
4650
if (wfstats.isDirectory()) {
4751
wffile = pathtool.join(wfpath, "workflow.json");
4852
} else if (wfstats.isFile()) {
4953
wffile = wfpath;
5054
wfpath = pathtool.dirname(wfpath);
5155
}
5256

53-
var runWf = function(wfId) {
57+
var runWf = function(wfId) {
5458
var config = {"emulate":"false", "workdir": pathtool.resolve(wfpath)};
5559
var engine = new Engine(config, wflib, wfId, function(err) {
5660
// This represent custom plugin listening on event from available eventServer
@@ -62,7 +66,7 @@ function hflow_run() {
6266
if (opts['-s']) {
6367
// Flag -s is present: send all input signals to the workflow -> start execution
6468
wflib.getWfIns(wfId, false, function(err, wfIns) {
65-
engine.wflib.getSignalInfo(wfId, wfIns, function(err, sigs) {
69+
engine.wflib.getSignalInfo(wfId, wfIns, function(err, sigs) {
6670
engine.emitSignals(sigs);
6771
});
6872
});
@@ -75,7 +79,7 @@ function hflow_run() {
7579
rcl.select(dbId, function(err, rep) {
7680
//rcl.flushdb(function(err, rep) { // flushing db here deletes the global 'hfid' entry (created earlier)
7781
wflib.createInstanceFromFile(wffile, '', function(err, id) {
78-
cb(err, id);
82+
cb(err, id);
7983
});
8084
//});
8185
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"ejs": "0.8.4",
1616
"eyes": "0.1.8",
1717
"async": "0.2.x",
18-
"redis": "0.9.1",
18+
"redis": "2.4.2",
1919
"xml2js": "0.2.7",
2020
"underscore": "1.x",
2121
"uuid": "",

server/hyperflow-server.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
** HyperFlow engine
33
** Author: Bartosz Balis (2012-2014)
4-
**
4+
**
55
** HyperFlow server implementing the REST API for HyperFlow workflows.
66
*/
77

@@ -11,14 +11,16 @@
1111
* Module dependencies.
1212
*/
1313

14+
15+
var redisURL = process.env.REDIS_URL ? {url: process.env.REDIS_URL} : {};
1416
// for express
1517
var express = require('express'),
1618
cons = require('consolidate'),
1719
http = require('http'),
1820
app = express();
1921

2022
var redis = require('redis'),
21-
rcl = redis.createClient();
23+
rcl = redis.createClient(redisURL);
2224

2325
var server = http.createServer(app);
2426
var wflib = require('../wflib').init(rcl);
@@ -91,15 +93,15 @@ app.post('/apps', function(req, res) {
9193
var wfJson = req.body;
9294
var baseUrl = '';
9395
//onsole.log(wfJson);
94-
96+
9597
// FIXME: validate workflow description
9698
// FIXME: add proper/more detailed error info instead of "badRequest(res)"
9799
wflib.createInstance(wfJson, baseUrl, function(err, appId) {
98-
if (err) return badRequest(res);
100+
if (err) return badRequest(res);
99101
engine[appId] = new Engine({"emulate": "false"}, wflib, appId, function(err) {
100-
if (err) return badRequest(res);
102+
if (err) return badRequest(res);
101103
engine[appId].runInstance(function(err) {
102-
if (err) return badRequest(res);
104+
if (err) return badRequest(res);
103105
res.header('Location', req.url + '/' + appId);
104106
res.send(201, null);
105107
//res.redirect(req.url + '/' + appId, 302);
@@ -129,7 +131,7 @@ app.get('/apps/:i', function(req, res) {
129131
wfname: "Application",
130132
wfins: appIns,
131133
wfouts: appOuts,
132-
stat: wfInstanceStatus,
134+
stat: wfInstanceStatus,
133135
now: (new Date()).getTime(),
134136
submit_inputs_uri: '/apps/'+appId
135137
}, function(err, html) {
@@ -161,7 +163,7 @@ app.get('/apps/:i', function(req, res) {
161163

162164
// emits a signal to a workflow
163165
// body must be a valid signal representation, such as:
164-
// {
166+
// {
165167
// "name": <signame>
166168
// <attr>: <value>
167169
// "data": [ sig(s) data ]

0 commit comments

Comments
 (0)