Rake assets:precompile gets killed when there is a console session open in production

后端 未结 5 1733
余生分开走
余生分开走 2020-12-28 17:35

On my production server, which is hosted on digital ocean, if that helps, Ubuntu 12.04, I have RoR 4 and rake 10.1.1.

When I deploy, I run rake assets:precompi

5条回答
  •  盖世英雄少女心
    2020-12-28 18:24

    Your precompile process is probably being killed because you are running out of RAM. You can confirm this by running top in another ssh session. To fix this, create a swap file that will be used when RAM is full.

    Create SWAP Space on Ubuntu You will probably end up needing some swap space if you plan on using Rails on Digital Ocean 512MB RAM droplet. Specifically, you will run out of RAM when compiling the assets resulting in the process being quietly killed and preventing successful deployments.

    To see if you have a swap files:

    sudo swapon -s
    

    No swap file shown? Check how much disk space space you have:

     df
    

    To create a swap file:

    Step 1: Allocate a file for swap

    sudo fallocate -l 2048m /mnt/swap_file.swap
    

    Step 2: Change permission

    sudo chmod 600 /mnt/swap_file.swap
    

    Step 3: Format the file for swapping device

    sudo mkswap /mnt/swap_file.swap
    

    Step 4: Enable the swap

    sudo swapon /mnt/swap_file.swap
    

    Step 5: Make sure the swap is mounted when you Reboot. First, open fstab

    sudo nano /etc/fstab
    

    Finally, add entry in fstab (only if it wasn't automatically added)

    # /etc/fstab
    /mnt/swap_file.swap none swap sw 0 0 
    

    Save and exit. You're done adding swap. Now your rake assets:precompile should complete without being killed.

提交回复
热议问题