ericclemmons / grunt-express-server

Grunt task for running an Express Server that works great with LiveReload + Watch/Regarde

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot stop server

andrey-buligin opened this issue · comments

Hi,
I am experiencing issues with proper way of closing server.

Here is my watch config
watch: {
compass: {
files: ['<%= yeoman.app %>/styles/{,/}.{scss,sass}'],
tasks: ['compass']
},

        livereload: {
            files: [
                '<%= yeoman.app %>/*.html',
                '{.tmp,<%= yeoman.app %>}/styles/{,**/}*.css',
                '{.tmp,<%= yeoman.app %>}/scripts/{,*/,**/,**/**/}*.js',
                '<%= yeoman.app %>/templates/{,*/,**/,**/**/}*.hbs',
                '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp}',
                'test/spec/{,**/}*.js'
            ],
              options: {
                livereload: 35712
            }
        },

        express: {
            files:  [
                '<%= yeoman.dist %>/*',
                'server/*'
            ],
            tasks: ['express:prod:stop', 'express:prod'],
            options: {
                spawn: false
            }
        }
    };

Here is my grunt task for executing build, build server, opening browser and then watching for changes in dist folder.
grunt.task.run(['build', 'express:prod', 'open:prod', 'watch:express']);

I expect that every time build folder/server files are modified running server should stop and start again. I could see that during 'express:prod:stop' command inside stop Action of server.js 'server' variable is 'undefined' (line 114) so there is nothing to kill. Please suggest how to kill server/process that's already running.

Thanks

options: {
  spawn: false
}

should be in the watch task and not in the express task
then it will work

Hi Paul, thanks for response. It's actually Watch->expres, it's not express, first few lines are not included in "code area", anyways I managed to solve issues after updating package to latest version mine was outdated. Thanks