DaniDeveloper
DaniDeveloper

Reputation: 41

Symfony 2 assetic:dump UglifyCss causes [Symfony\Component\Process\Exception\RuntimeException] The process has been signaled with signal "5"

I'm developing my first Symfony 2 app, and I'm trying Uglify to minimize my .css files. The problem is that when I execute the command:

$ /Applications/mampstack-5.4.17-0/php/bin/php app/console assetic:dump --verbose

I get the following result:

Dumping all dev assets.
Debug mode is on.

17:22:09 [file+] /Users/bender22/Proyectos/ETraining/app/../web/examlayout.css
        /Users/bender22/Proyectos/ETraining/app/../web/bundles/exam/css/exam.css
        /Users/bender22/Proyectos/ETraining/app/../web/bundles/exam/css/exam3.css

[Symfony\Component\Process\Exception\RuntimeException]
The process has been signaled with signal "5".

Exception trace:

() at /Users/bender22/Proyectos/ETraining/vendor/symfony/symfony/src/Symfony/Component/Process/Process.php:428
Symfony\Component\Process\Process->wait() at /Users/bender22/Proyectos/ETraining/vendor/symfony/symfony/src/Symfony/Component/Process/Process.php:204
Symfony\Component\Process\Process->run() at /Users/bender22/Proyectos/ETraining/vendor/kriswallsmith/assetic/src/Assetic/Filter/UglifyCssFilter.php:106
Assetic\Filter\UglifyCssFilter->filterDump() at /Users/bender22/Proyectos/ETraining/vendor/kriswallsmith/assetic/src/Assetic/Filter/FilterCollection.php:69
Assetic\Filter\FilterCollection->filterDump() at /Users/bender22/Proyectos/ETraining/vendor/kriswallsmith/assetic/src/Assetic/Asset/BaseAsset.php:108
Assetic\Asset\BaseAsset->dump() at /Users/bender22/Proyectos/ETraining/vendor/kriswallsmith/assetic/src/Assetic/Asset/AssetCollection.php:151
Assetic\Asset\AssetCollection->dump() at /Users/bender22/Proyectos/ETraining/vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php:222
Symfony\Bundle\AsseticBundle\Command\DumpCommand->doDump() at /Users/bender22/Proyectos/ETraining/vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php:162
Symfony\Bundle\AsseticBundle\Command\DumpCommand->dumpAsset() at /Users/bender22/Proyectos/ETraining/vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php:61
Symfony\Bundle\AsseticBundle\Command\DumpCommand->execute() at /Users/bender22/Proyectos/ETraining/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:244
Symfony\Component\Console\Command\Command->run() at /Users/bender22/Proyectos/ETraining/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:904
Symfony\Component\Console\Application->doRunCommand() at /Users/bender22/Proyectos/ETraining/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:191
Symfony\Component\Console\Application->doRun() at /Users/bender22/Proyectos/ETraining/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:85
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /Users/bender22/Proyectos/ETraining/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:121
Symfony\Component\Console\Application->run() at /Users/bender22/Proyectos/ETraining/app/console:27

My environment:

OS: Mac OS 10.8.4
Symfony: 2.3.2
symfony/assetic-bundle: 2.3.0
kriswallsmith/assetic: 1.1.2
Bitnami Mampstack: 5.4.17
Node.js: 0.10.13
Php: 5.4.17
Apache: 2.4.4

Here are some relevant information:

My config.yml:

assetic:
    debug:          %kernel.debug%
    use_controller: false
    bundles:        [ExamBundle]
    java: /usr/bin/java
    filters:
        cssrewrite: ~
        uglifyjs2:  # the path to the uglifyjs executable
            bin: /usr/local/bin/uglifyjs
            node: /usr/local/bin/node
        uglifycss:  # the path to the uglifycss executable
            bin: /usr/local/bin/uglifycss
            node: /usr/local/bin/node

My Twig template:

{% block stylesheets %}
    {% stylesheets output='css/generated/examlayout.css' filter='cssrewrite, uglifycss' debug=false
        'bundles/exam/css/exam.css'
        'bundles/exam/css/exam3.css'
    %}
    <link href="{{ asset_url }}" rel="stylesheet" />
    {% endstylesheets %}
{% endblock %}

Some of the things that I've already tested without any luck:

1) Execute the command (without specify /Applications/mampstack-5.4.17-0/php/bin/php )

$ app/console assetic:dump --verbose

The result is

Dumping all dev assets.
Debug mode is on.

17:55:12 [file+] /Users/bender22/Proyectos/ETraining/app/../web/css/generated/examlayout.css
    /Users/bender22/Proyectos/ETraining/app/../web/bundles/exam/css/exam.css
    /Users/bender22/Proyectos/ETraining/app/../web/bundles/exam/css/exam3.css

The result file in web/css is correct (the content includes both .css files minimized). The problem is that when I load the Web page, the .css is broken:

<link href="/app_dev.php/css/generated/examlayout.css" rel="stylesheet" />

and if I click on the href, the content the browser shows is:

/*
[exception] 500 | Internal Server Error | Symfony\Component\Process\Exception\RuntimeException
[message] The process has been signaled with signal &quot;5&quot;.
[1] Symfony\Component\Process\Exception\RuntimeException: The process has been signaled with  
signal &quot;5&quot;.
at n/a
    in /Users/bender22/Proyectos/ETraining/vendor/symfony/symfony/src/Symfony/Component/Process 
    /Process.php line 428
at Symfony\Component\Process\Process-&gt;wait(null)
    in /Users/bender22/Proyectos/ETraining/vendor/symfony/symfony/src/Symfony/Component/Process
   /Process.php line 204
at Symfony\Component\Process\Process-&gt;run()
    in /Users/bender22/Proyectos/ETraining/vendor/kriswallsmith/assetic/src/Assetic/Filter
   /UglifyCssFilter.php line 106
at Assetic\Filter\UglifyCssFilter-&gt;filterDump(object(FileAsset))
    in /Users/bender22/Proyectos/ETraining/vendor/kriswallsmith/assetic/src/Assetic/Filter
   /FilterCollection.php line 69
at Assetic\Filter\FilterCollection-&gt;filterDump(object(FileAsset))
    in /Users/bender22/Proyectos/ETraining/vendor/kriswallsmith/assetic/src/Assetic/Asset
   /BaseAsset.php line 108
at Assetic\Asset\BaseAsset-&gt;dump(null)
    in /Users/bender22/Proyectos/ETraining/vendor/kriswallsmith/assetic/src/Assetic/Asset
  /AssetCollection.php line 151
at Assetic\Asset\AssetCollection-&gt;dump(null)
    in /Users/bender22/Proyectos/ETraining/vendor/kriswallsmith/assetic/src/Assetic/Asset
  /AssetCache.php line 69
at Assetic\Asset\AssetCache-&gt;dump()
    in /Users/bender22/Proyectos/ETraining/vendor/symfony/assetic-bundle/Symfony/Bundle
  /AsseticBundle/Controller/AsseticController.php line 88
at Symfony\Bundle\AsseticBundle\Controller\AsseticController-&gt;render(&#039;6a1dad3&#039;, 
null)
    in  line 
at call_user_func_array(array(object(AsseticController), &#039;render&#039;), 
    array(&#039;6a1dad3&#039;, null))
    in /Users/bender22/Proyectos/ETraining/app/bootstrap.php.cache line 2774
at Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(object(Request), &#039;1&#039;)
    in /Users/bender22/Proyectos/ETraining/app/bootstrap.php.cache line 2748
at Symfony\Component\HttpKernel\HttpKernel-&gt;handle(object(Request), &#039;1&#039;, true)
    in /Users/bender22/Proyectos/ETraining/app/bootstrap.php.cache line 2878
at Symfony\Component\HttpKernel\DependencyInjection
    \ContainerAwareHttpKernel-&gt;handle(object(Request), &#039;1&#039;, true)
    in /Users/bender22/Proyectos/ETraining/app/bootstrap.php.cache line 2179
at Symfony\Component\HttpKernel\Kernel-&gt;handle(object(Request))
    in /Users/bender22/Proyectos/ETraining/web/app_dev.php line 28

*/

2) Set folder privileges with (in a recursive way):

chmod 777

for the folders: web (inside my Symfony project) and my temp folder, which turns out to be:

/var/folders/hp/vv24wsq56bs9szlt7j8bt3600000gn/T

Could you please help me out to solve this? I've ran out of ideas.

Note: I've tagged this as uglifyjs2 because I don't have enough points for creating the tag uglifycss

Thanks in advance :)

Upvotes: 4

Views: 2970

Answers (1)

Joost Farla
Joost Farla

Reputation: 66

We had the same issue with the uglifycss filter running out of memory with big css files without a proper error message.

You can show the exact error message by following the following steps:

  • disable uglifycss filter in your assetic configuration
  • run assetic:dump task
  • navigate to the dir where the css files are generated, probably web/css
  • run uglifycss <filename> > test.css for each generated css file
  • see which file returns an error

We solved our issue by overriding the UglifyCssFilter class and adding a custom Node.js parameter for a higher memory limit:

<?php

namespace Acme\DemoBundle\Filter;

use Assetic\Filter\UglifyCssFilter as BaseUglifyCssFilter;

class UglifyCssFilter extends BaseUglifyCssFilter
{
    protected function createProcessBuilder(array $arguments = array())
    {
        if ($arguments[0] === '/usr/bin/node') {
            $arguments = array_merge(array(
                $arguments[0],
                '--max-old-space-size=4096'
            ), array_slice($arguments, 1));
        }

        return parent::createProcessBuilder($arguments);
    }
}

You have to change the Node path to the correct location (or improve the comparison in some other way).

You can let Assetic use this class by setting a service parameter in your config file:

parameters:
    assetic.filter.uglifycss.class: Acme\DemoBundle\Filter\UglifyCssFilter

Upvotes: 1

Related Questions