gruntjs / grunt-contrib-connect

Start a static web server.
http://gruntjs.com
MIT License
714 stars 146 forks source link

Kill server on CTRL-C #187

Closed LeleDev closed 9 years ago

LeleDev commented 9 years ago

How can I kill the server when the grunt task is interrupted using CTRL-C?

In start my connect task before a watch task. Then if I kill grunt using CTRL-C, the next time i start these task I get the following error:

Fatal error: Port 8000 is already in use by another process.

Unless I manually kill the grunt process.

Thank you in advance

adepatie commented 9 years ago

What does your gruntfile look like?

LeleDev commented 9 years ago
module.exports = function(grunt) {

   // Project configuration
   grunt.initConfig({
       pkg: grunt.file.readJSON('package.json'),
       sass: {
           options: {
               sourcemap: 'none'
           },
           src: {
               files: [
                  {
                      expand: true,
                      cwd: '/app/scss/',
                      src: ['*.scss'],
                      dest: '/app/css/sass',
                      ext: '.css'
                  }
               ]
           },

       },
       watch: {
          sass: {
              files: [
                 'app/scss/*.scss',
              ],
              tasks: ['sass:src'],
          },
       },
       connect: {
          server: {
              options: {
                  port: 8000,
                  open: true
              }
          }
       }
   });

  // Load the plugin that provides tasks
  grunt.loadNpmTasks('grunt-contrib-sass');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-connect');

  grunt.registerTask('default', [
      'connect:server',
      'watch'
  ]);

};
adepatie commented 9 years ago

Have you tried changing the port and seeing if it still happens?

LeleDev commented 9 years ago

Tried right now.. the issue doesn't occur changing the port!