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

Closing sessions #37

Open
sensaetions opened this issue Feb 7, 2017 · 10 comments
Open

Closing sessions #37

sensaetions opened this issue Feb 7, 2017 · 10 comments

Comments

@sensaetions
Copy link

sensaetions commented Feb 7, 2017

Hello, I am using gulp-connect-php on a lot of different projects to serve up my PHP pages. Sometimes I would start one server on one project, and then have to switch to a different project. I make sure to close the connection by ending the gulp task. However, when I switch to the different project and run my gulp task, the connection opens the previous site instead.

So far, the only way I can close off the connection completely is to restart my computer. That is not practical in the long run. How can I make it so that previous connection ends completely and loads the appropriate site? Thank you in advance.

Below is an example of my gulp task.

gulp.task('connect', function () {
    connect.server({
        root: 'src',
        livereload: true
    });
});

gulp.task('connectSync', ['connect'], function () {
    connectPhp.server({}, function () {
        browserSync({
            proxy: 'localhost:8000',
            open: {
                browser: 'Google Chrome'
            }
        });
    });
});
@micahblu
Copy link
Owner

Sorry for the late reply on this. Can you please provide me some environment specifics? What os, php version etc.

@vieko
Copy link

vieko commented Apr 16, 2017

Hey there, I just ran into this issue on OSX Sierra with PHP 5.6/7.0/7.1 – the php process simply does not terminate when I stop the gulp task from running. Managed to kill the process by locating it first with lsof -i tcp:8000 and then killing the PID. Any thoughts? Thanks in advance.

EDIT: sometimes things will work as expected. Managed to reproduce a few times however.

@grmartin
Copy link
Collaborator

grmartin commented Apr 17, 2017

@vieko I am presently in the process of reworking portions of this, including its dependence on lsof. The current status of where i am in this is available here: #41

You are welcome (encouraged) to test that out and see how it goes.

Please direct any bugs against 1.0.0 WIP against the other repo (https://github.com/grmartin/gulp-connect-php). Once it is merged in to this one, bug tracking will move here, i simply do not wish to muddy the waters in this repo until after that branch is mainlined.

@grmartin
Copy link
Collaborator

1.0.0 is now in the primary master branch of the original repository. See: http://github.com/micahblu/gulp-connect-php.

@grmartin
Copy link
Collaborator

grmartin commented May 8, 2017

This ticket will close on or near 17 May 2017 unless updated.

@dylanspurgin
Copy link

dylanspurgin commented May 20, 2017

I am also seeing the behavior where the server does not stop when the gulp process is ended (MacOS). My gulp task looks like this:

gulp.task('connect', ['browsersync'], function () {
    connect.server({ base: config.wordpress.dest, port: 8001, debug: true, open: false});
});

@grmartin
Copy link
Collaborator

grmartin commented May 20, 2017

So, Gulp 3 uses orchestrator. Presently our library doesn't implement any binding to Gulp's events. That would be why its not 'automatically' stopping, there is a closeServer call.

For now i would suggest adding a handler yourself... Should be something much like this (based on @dylanspurgin's code in his comment):

gulp.task('connect', ['browsersync'], function () {
    connect.server({ base: config.wordpress.dest, port: 8001, debug: true, open: false}, function() {
    	gulp.on('stop', function _gulp_php_stopper() {
    		connect.closeServer();
    	});
    });
});

I will however add this to my TODO list.

@grmartin
Copy link
Collaborator

@micahblu, I can add this but I'd like to make it so it can be opted out from via a configure parameter... any issues with that conceptually?

@micahblu
Copy link
Owner

Not at all, let's go for it

@Jikstra
Copy link

Jikstra commented Apr 16, 2018

So, Gulp 3 uses orchestrator. Presently our library doesn't implement any binding to Gulp's events. That would be why its not 'automatically' stopping, there is a closeServer call.

For now i would suggest adding a handler yourself... Should be something much like this (based on @dylanspurgin's code in his comment):

gulp.task('connect', ['browsersync'], function () {
   connect.server({ base: config.wordpress.dest, port: 8001, debug: true, open: false}, function() {
   	gulp.on('stop', function _gulp_php_stopper() {
   		connect.closeServer();
   	});
   });
});

I will however add this to my TODO list.

Not sure why, but for me the gulp stop event gets fired way to early. I replaced it with following code and seems to work, even if it also feels hacky.

      process.on('exit', () => {
          console.log('Shutting down php server');
          gulpConnectPhp.closeServer()
      });

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

6 participants