Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stopping a task from watch does not seem to work #23

Open
nicojs opened this issue Feb 5, 2016 · 2 comments
Open

Stopping a task from watch does not seem to work #23

nicojs opened this issue Feb 5, 2016 · 2 comments

Comments

@nicojs
Copy link

nicojs commented Feb 5, 2016

When you try to stop a task in a watch when which was started before you get the following error:

Running "stop:server" (stop) task
Verifying property stop.server exists in config...ERROR
>> Unable to process task.
Warning: Required config property "stop.server" missing. Use --force to continue.

Aborted due to warnings.

This might be by design because watch starts a new grunt process or something, but i feel like it should work. Example grunt file:

module.exports = function (grunt) {
  require('load-grunt-tasks')(grunt);

  grunt.initConfig({
    watch: {
      ts: {
        files: ['**/*.ts'],
        tasks: ['stop:server', 'build', 'run:server']
      }
    },

    run: {
      server: {
        options: {
          wait: false,
          ready: /.*Listening on port.*/ig
        },
        args: ['./dist/app/index.js'],
      }
    },

    ts: {
      src: {
        tsconfig: true
      }
    }
  });

  grunt.registerTask('build', ['clean', 'ts']);
  grunt.registerTask('serve', ['build', 'run:server', 'watch']);
}
@spalger
Copy link
Owner

spalger commented Feb 12, 2016

Yes, this is the case. Ideally grunt-run could use a file-system pid file collection or something, so the active processes are known across processes, but that opens us up to race conditions that I'm not looking to prevent right now. The easiest solution is to tell watch not to spawn a new process: https://github.com/gruntjs/grunt-contrib-watch#why-spawn-as-child-processes-as-a-default

@neophob
Copy link

neophob commented Mar 11, 2016

Well I tried that (not spawn for watch), the result is that the error is gone now but my express application is running twice now. any hints?

Edit: It might be an application specific issue, for example grunt-express-server has the same issue.
Edit2: In my case the reason was, that I had a setInterval function running - this prevented stopping the server cleanly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants