hiddentao / gulp-server-livereload

Gulp plugin to run a local webserver with livereload enabled via socket.io. Also comes with standalone command-line interface.
MIT License
93 stars 28 forks source link

Multiple "Webserver started at http://localhost:8000" messages #35

Closed davestewart closed 8 years ago

davestewart commented 8 years ago

I'm just getting to grips with watching a bunch of files, and responding accordingly, but I've noticed that the more times I stop and start the gulp task, the more "Webserver started at http://localhost:8001" messages appear.

Below is the trace from a single gulp call:

Dave@MacBook-Pro:/Volumes/Data/Work/OpenSource/PHP/Laravel/Laravel Doodle/doodle-demo/support$ gulp
[22:28:42] Livereload started at http://localhost:35729
[22:28:42] Using gulpfile /Volumes/Data/Work/OpenSource/PHP/Laravel/Laravel Doodle/doodle-demo/support/gulpfile.js
[22:28:42] Starting 'default'...
[22:28:42] Finished 'default' after 29 ms
[22:28:42] Webserver started at http://localhost:8001
[22:28:42] Webserver started at http://localhost:8001
[22:28:42] Webserver started at http://localhost:8001
[22:28:42] Webserver started at http://localhost:8001
[22:28:42] Webserver started at http://localhost:8001
[22:28:42] Webserver started at http://localhost:8001
[22:28:42] Webserver started at http://localhost:8001
[22:28:42] Webserver started at http://localhost:8001
[22:28:42] Webserver started at http://localhost:8001
[22:28:42] Webserver started at http://localhost:8001
[22:28:42] Webserver started at http://localhost:8001
[22:28:42] Webserver started at http://localhost:8001
[22:28:42] Webserver started at http://localhost:8001
[22:28:42] Webserver started at http://localhost:8001
[22:28:42] Webserver started at http://localhost:8001
[22:28:42] Webserver started at http://localhost:8001
[22:28:42] Webserver started at http://localhost:8001
[22:28:42] Webserver started at http://localhost:8001
[22:28:42] Webserver started at http://localhost:8001

Is this bad? Am I doing something wrong?

hiddentao commented 8 years ago

How are you stopping and starting it? I don't get this problem myself.

davestewart commented 8 years ago

Hey Ramesh,

Thanks for getting back to me!

I'm often not stopping anything - I assume Node takes care of that for me when I CTRL+C?

I just restarted PHPStorm, and ran the gulpfile afresh, and got 42 lines of "webserver started at..."

This is my gulpfile:

https://github.com/davestewart/laravel-sketchpad-demo/blob/master/support/gulpfile.js

Does that shed any light on things?

davestewart commented 8 years ago

Today I'm getting 100+ webserver started lines.

My machine has just had a restart, and I killed all node tasks before running anything.

This is the result of a single gulp call from the terminal, in conjunction with some other tasks:

Last login: Fri May 27 10:14:54 on ttys001
Dave@MacBook-Pro:/Volumes/Data/Work/Current/2015-07 - Timeslice, Kiosk 3.0/timeslice.kiosk/support$ gulp
[10:33:43] Livereload started at http://localhost:35729
[10:33:43] Using gulpfile /Volumes/Data/Work/Current/2015-07 - Timeslice, Kiosk 3.0/timeslice.kiosk/support/gulpfile.js
[10:33:43] Starting 'default'...
[10:33:43] Starting 'build'...
[10:33:43] Starting 'styles'...
[10:33:43] Starting 'scripts'...
[10:33:43] Finished 'build' after 10 ms
[10:33:43] Starting 'watch'...
[10:33:43] Finished 'watch' after 28 ms
[10:33:43] Finished 'default' after 48 ms
[10:33:43] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] /Volumes/Data/Work/Current/2015-07 - Timeslice, Kiosk 3.0/timeslice.kiosk/public/assets/css/admin.css reloaded.
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] /Volumes/Data/Work/Current/2015-07 - Timeslice, Kiosk 3.0/timeslice.kiosk/public/assets/css/kiosk.css reloaded.
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] /Volumes/Data/Work/Current/2015-07 - Timeslice, Kiosk 3.0/timeslice.kiosk/public/assets/css/media.css reloaded.
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Finished 'styles' after 380 ms
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] /Volumes/Data/Work/Current/2015-07 - Timeslice, Kiosk 3.0/timeslice.kiosk/public/assets/js/all.min.js reloaded.
[10:33:44] Finished 'scripts' after 376 ms
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001
[10:33:44] Webserver started at http://localhost:8001

If I just run this task:

    function livereloadProject()
    {
        var source =
        [
            '../app/**/*.php',
            '../sketchpad/**/*.php'
        ];

        gulp.src(source)
            .pipe(server({
                livereload: {
                    enable: true,
                    filter: function (filename, cb) {
                        var state = ! /\.(sa|le)ss$|node_modules/.test(filename);
                        cb(state);
                    }
                },
                directoryListing: false,
                open: false,
                port:8001
            }));
    }

    gulp.task('lr-project', livereloadProject);

...I get the following:

[10:37:48] Using gulpfile /Volumes/Data/Work/Current/2015-07 - Timeslice, Kiosk 3.0/timeslice.kiosk/support/gulpfile.js
[10:37:48] Starting 'lr-project'...
[10:37:48] Livereload started at http://localhost:35729
[10:37:48] Finished 'lr-project' after 18 ms
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
[10:37:48] Webserver started at http://localhost:8001
hiddentao commented 8 years ago

That's so weird. Ok, I think I need to look at this this coming week.

hiddentao commented 8 years ago

Took a look at your gulpfile. The problem is here:

            var source =
            [
                vendor  + 'resources/views/**/*',
                project + 'public/vendor/sketchpad/**/*.+(css|js)',
                project + 'app/Http/Controllers/Sketchpad/**/*.php'
            ];

            gulp.src(source)
                .pipe(serverInstance);

The pipe(serverInstance) is going to get executed for every file that gulp.src finds.

davestewart commented 8 years ago

Ah, that will be why then!

To be honest, I was always using gulp-server-livereload in a bit of a bastardised way, generally as I didn't know exactly what I needed in my gulp setup.

I wanted it for exposing __onLiveReloadFileChangedbut have since monkey-patched LiveReload.reloader.reload() client-side, so now I can get away with a simple gulp-watch.

Thanks for looking at it anyway, and sorry for wasting your time!