I can't start the php standalone server from gulp. I use the start_server function shown below to spawn the child process and watch the stdout / stderr until a sentinel text is discovered that indicates the service is available for use. This works fine with web-driver and other services, but not for php standalone.
var start_server = function(options, cb) {
var child = child_process.spawn(options.command, options.arguments, {
detached: true,
cwd: process.cwd,
env: process.env,
stdio: ['pipe', 'pipe', 'pipe']
});
child.once('close', cb);
child.unref();
if (child.stdout) child.stdout.on('data', function(data) {
gutil.log(gutil.colors.yellow(data));
var sentinal = options.sentinal;
if (data.toString().indexOf(sentinal) != -1) {
cb(null, child);
}
});
if (child.stderr) child.stderr.on('data', function(data) {
gutil.log(gutil.colors.red(data));
var sentinal = options.sentinal;
if (data.toString().indexOf(sentinal) != -1) {
cb(null, child);
}
});
};
gulp.task('start-php', function(cb) {
var options = {
command: '/usr/bin/php',
arguments: ['-S', 'localhost:8000', '-t', 'htdocs'],
sentinal: 'Press Ctrl-C to quit.'
};
start_server(options, cb);
//execute('/usr/bin/php -S localhost:8000 -t htdocs &', null, cb);
});
The 'Press Ctrl-C to quit' is never seen by the start_server function.