rails assets pipeline “Cannot allocate memory - nodejs”

后端 未结 5 1479
野趣味
野趣味 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:23

    Based on @tohi's answer, I created a script which you can paste into a terminal.

    # Turn it (off) on
    # sudo swapoff -a
    sudo swapon -s
    
    # Create a swap file
    # 512k --> Swapfile of 512 MB
    sudo dd if=/dev/zero of=/swapfile bs=1024 count=512k
    
    # Use the swap file
    sudo mkswap /swapfile
    sudo swapon /swapfile
    
    # make sure the swap is present after reboot:
    sudo echo " /swapfile       none    swap    sw      0       0 " >> /etc/fstab
    
    # Set the swappiness (performance - aware)
    echo 10 | sudo tee /proc/sys/vm/swappiness
    echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf           
    
    # Change the permission to non-world-readable
    sudo chown root:root /swapfile 
    sudo chmod 0600 /swapfile
    

    Update: If you need to resize the /swapfile at a later point check out this answer: https://askubuntu.com/a/763717/508371

提交回复
热议问题