aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-10-25 11:58:23 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2015-10-25 11:58:23 +0100
commit1b77c103b2fe6532ddf8f0625ebafeec8c1f5304 (patch)
treea4cb1fe01d6fccfba73c918b1b60a475a09f02e5
parente8ec4001ce1297d5a3db6d3fc8af8de47daa6a61 (diff)
downloaddiller-server-1b77c103b2fe6532ddf8f0625ebafeec8c1f5304.tar.gz
diller-server-1b77c103b2fe6532ddf8f0625ebafeec8c1f5304.tar.bz2
diller-server-1b77c103b2fe6532ddf8f0625ebafeec8c1f5304.tar.xz
diller-server-1b77c103b2fe6532ddf8f0625ebafeec8c1f5304.zip
o Experimenting with grunt.
-rw-r--r--README.md6
-rw-r--r--diller-mqtt.js (renamed from diller.js)0
-rw-r--r--gulpfile.js75
-rw-r--r--package.json6
4 files changed, 85 insertions, 2 deletions
diff --git a/README.md b/README.md
index 092fba3..387098c 100644
--- a/README.md
+++ b/README.md
@@ -8,8 +8,10 @@ Create a database user and database called 'diller' with the password 'diller' a
Run Diller:
- node diller.js | node_modules/.bin/bunyan
-
+ gulp diller-mqtt
+
+This assumes that you have `gulp` installed globally. If you don't you can run `./node_modules/.bin/gulp`.
+
# MQTT topics
/diller
diff --git a/diller.js b/diller-mqtt.js
index db6fc2b..db6fc2b 100644
--- a/diller.js
+++ b/diller-mqtt.js
diff --git a/gulpfile.js b/gulpfile.js
new file mode 100644
index 0000000..ae66565
--- /dev/null
+++ b/gulpfile.js
@@ -0,0 +1,75 @@
+var gulp = require('gulp-help')(require('gulp'));
+var bower = require('gulp-bower');
+var nodemon = require('gulp-nodemon');
+var path = require('path');
+var spawn = require('child_process').spawn
+
+gulp.task('bower', function () {
+ return bower()
+});
+
+function readable(state, daemon) {
+ var bunyan = state.bunyan;
+
+ // free memory
+ bunyan && bunyan.kill();
+
+ bunyan = state.bunyan = spawn('./node_modules/.bin/bunyan', [
+ '--output', 'short',
+ '--color'
+ ]);
+
+ //console.log('bunyan', bunyan);
+ bunyan.stdout.pipe(process.stdout);
+ bunyan.stderr.pipe(process.stderr);
+
+ daemon.stdout.pipe(bunyan.stdin);
+ daemon.stderr.pipe(bunyan.stdin);
+}
+
+gulp.task('diller-mqtt-reload', function () {
+});
+
+gulp.task('diller-mqtt', function () {
+ var state = {};
+
+ nodemon({
+ script: 'diller-mqtt.js',
+ delay: 500,
+ ext: 'js',
+ watch: [
+ 'src'
+ ],
+ ignore: [
+ 'src/web/'
+ ],
+ env: {NODE_ENV: 'development'},
+ tasks: ['diller-mqtt-reload'],
+ stdout: false,
+ //readable: false,
+ a: ''
+ }).on('readable', function () {
+ return readable(state, this);
+ });
+});
+
+gulp.task('diller-web-reload', function () {
+});
+
+gulp.task('diller-web', ['bower'], function () {
+ nodemon({
+ script: 'diller-web.js',
+ delay: 500,
+ ext: 'js',
+ watch: [
+ 'src'
+ ],
+ ignore: [
+ 'src/mqtt/'
+ ],
+ env: {NODE_ENV: 'development'},
+ tasks: ['diller-web-reload']
+ });
+});
+
+gulp.task('default', ['bower']);
diff --git a/package.json b/package.json
index 6f822ad..2c082af 100644
--- a/package.json
+++ b/package.json
@@ -19,5 +19,11 @@
"mqtt": "^1.4.3",
"pg": "^4.4.2",
"pg-promise": "^2.0.12"
+ },
+ "devDependencies": {
+ "gulp": "^3.9.0",
+ "gulp-bower": "0.0.10",
+ "gulp-help": "^1.6.1",
+ "gulp-nodemon": "^2.0.4"
}
}