Reputation: 18595
I am trying to run a watch
task in my Gruntfile.js
as a daemon.
Normally, I would execute this script like: grunt watch
.
module.exports = function(grunt) {
grunt.initConfig({
concat: {
options: {
separator: ''
},
dist: {
src: ['static/js/**/*.js'],
dest: 'app.js'
}
},
watch: {
files: ['<%= concat.dist.src %>'],
tasks: ['concat']
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
};
How do I spawn grunt watch
as a daemon?
It appears as though considerations for this have already been made:
https://github.com/shama/grunt-hub#watching-forever
https://github.com/shama/grunt-hub/issues/3
Upvotes: 4
Views: 6052
Reputation: 412
you can use https://github.com/nodejitsu/forever exmaple
forever start gruntstart.js
gruntstart.js:
var exec = require('child_process').exec;
exec('grunt watch > log/grunt.log',
function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});
Upvotes: 3
Reputation: 137
I'm a newbie in javascript, but I solved this problem with: tmux
Even if I close the console tmux will go on with watching :D
https://i.sstatic.net/4clqc.jpg
Upvotes: 0