Deployment problem in Symfony 1.4 – FIXED
Whom tried works with the symfony’s deployment – read symfony 1.4 -, probably had problems with it. This article, is about a peculiarity of the symfony deploy interface, in Windows environment, that have a simple and effective solution.
I tried to find related topics about this issue but I didn’t find anything. I believe that just few developers have the possibility to use shell accounts in hosting servers, consequently, the use of these tools, like rsync, are impaired.
Shared hosting not always provides the possibility to use a shell account, which is understandable. Well, if you don’t have a shell account, pay for one, and whether you have a shared hosting, rent a VPS or dedicated server. I had serious problems using a shared host, but I will explain it in another moment.
This problem started to occur when I migrated from symfony 1.2 to 1.4. It’s interesting to note that the way to execute shell commands on symfony 1.4 has changed. At 1.2 we have the passthru() while in the 1.4 we have the proc_open() – the first executes a shell command and returns raw output, the other executes a shell command (open a process) and open file pointers for input and output.
The problem actually isn’t in the symfony, but in the PHP function proc_open(), more specifically in the pipes created by PHP in the execution of rsync command – or any other command.This happens only in few moments where the STDERR stream is filled and it causes a freeze in the STDOUT stream that generates a infinity loop on Windows – Thanks to Luceo.
I confess that this problem was not so simple to fix, this is a very specific problem of PHP and Windows. However I propose two solutions for this problem:
The first solution, the right way, is to change the access mode of the STDERR pipe in the class sfFilesystem.class.php, line 291:
$descriptorspec = array(
1 => array('pipe', 'w'), // stdout
2 => array('pipe', 'a'), // stderr
);
This makes with that the pointer STDERR stream leaves from starting position – “w” mode – and goes to the final position – “a” mode. In others words, just change the pipe access mode and the problem will be resolved.
The second solution is so simple as the first. Simply customize the default rsync parameters of symfony, in others words, omit the parameter –progress. See the example below:
[production] host=www.domain.com port='22 -i E:\cygwin\home\Augusto\.ssh\id_rsa' user=domain dir=/home/domain/website parameters="-azC --force --delete --exclude-from=config/rsync_exclude.txt"
Recalling again: This problem happens only from symfony version 1.3 where was changed the way that’s shell commands are executed by symfony. Previously, it used the passthru() and now is used the proc_open().
I even open a ticket about this problem in the symfony bugtrac’s website but, until now, I didn’t get a reply of this issue. Therefore when I receive a answer I tell to you.
I didn’t look to the symfony 2.0 about this issue but when I have time I will look.
I hope that it helps you.
Augusto,
Just what I needed! Thank you!
Regards,
Paulo
I just had a quick read of #8177, and it looks like you closed this ticket without any changes going into the trunk. If you are not certain that this bug has been looked at by the core team, it would be worth re-opening the ticket, and resetting the version against the latest minor release of 1.4 (if, of course, it affects that version too).
Hi halfer,
I have posted the wrong link. Sorry about that. I already updated it.
http://trac.symfony-project.org/ticket/8507
Thanks for your comment.