rails assets pipeline “Cannot allocate memory - nodejs”

后端 未结 5 1463
野趣味
野趣味 2020-12-14 16:01

we\'ve just upgraded to Rails 3.2.5 from Rails 3.0.7 and using the assets-pipeline compilation on the fly for the staging server, but some times we face this exception !

5条回答
  •  一整个雨季
    2020-12-14 16:34

    Based on the tutorial link provided by Kyle Carlson


    Check swap space

    sudo swapon -s

    An empty list will confirm that you have no swap files enabled:

    Filename Type Size Used Priority

    Create and Enable the Swap File (swapfile)

    sudo dd if=/dev/zero of=/swapfile bs=1024 count=256k

    Create a linux swap area:

    sudo mkswap /swapfile

    output:

    Setting up swapspace version 1, size = 262140 KiB no label, UUID=103c4545-5fc5-47f3-a8b3-dfbdb64fd7eb
    

    Activate the swapfile:

    sudo swapon /swapfile

    check if you can see the swap summary.

    swapon -s
    
    Filename                Type        Size    Used    Priority
    /swapfile                               file        262140  0   -1
    

    Done!


    To make the swap file permenant

    sudo nano /etc/fstab

    Paste in the following line:

    /swapfile none swap sw 0 0

    Swappiness in the file should be set to 10. Skipping this step may cause both poor performance, whereas setting it to 10 will cause swap to act as an emergency buffer, preventing out-of-memory crashes.

    echo 10 | sudo tee /proc/sys/vm/swappiness
    echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf
    

    set up the correct permissions on the swap file to not readable by the public:

    sudo chown root:root /swapfile 
    sudo chmod 0600 /swapfile
    

提交回复
热议问题