Posts de fevereiro \25\UTC 2010|Página de posts mensais
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.
symfony cli colorido (Cygwin)
Olá a todos,
hoje vou dar um dica simples porém acredito que seja valiosa pra quem trabalho com o symfony no ambiente Windows. Gostaria de deixar em negrito que não aconselho optar pelo Windows como ambiente de produção. Apenas como uma alternativa para ambiente de desenvolvimento.
Você que trabalha ou já trabalhou com o symfony no ambiente Linux, já reparou que o cli do comando symfony apresenta cores. Porém ao trabalhar no Windows você não tem a mesma experiência. Isto é porque o Windows não escapa corretamente os caracteres ANSI. Por isto você não vê as cores.
Pois bem. Esta “colorização” – por assim dizer – pode ser habilitada usando um aplicativo chamado ANSICO do Jason Hood. É simples sua instalação. Basta fazer o download e copiar os arquivos ansicon.exe e ANSI.dll para algum diretório mapeado na variável PATH do seu Windows. Eu preferi fazer isto usando o caminho: c:/windows/system32 . Depois de copiar os arquivos é preciso instalá-lo no registro:
# ansicon -i
Simples, certo? Agora seu symfony exibe as cores em seu cygwin perfeitamente. As cores também ficam habilitadas no shell nativo do windows.
É importante ressaltar que esta “colorização” foi implementada – e passou a ter suporte no windows – somente a partir do symfony 1.3. Portanto se você usa alguma versão inferior a 1.3 este já é um dos motivos para migrar para a versão 1.4.
Espero ter ajudado.
Abraços.
Comentários (3)
