[SOLVED] RAILS_ENV=production rake db:migrate gets killed (for Digital Ocean 512MB RAM droplet)
The precompile process is killed because it’s eating out your server’s RAM. You can confirm this by running top in another ssh session. To solve it, we have to create a swap file that will be used when RAM is full.
First of all check if your system have any swap files
sudo swapon -s
No swap file shown? Check how much disk space space you have:
df
Here is the whole process of create and implement this swap files:
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 gedit /etc/fstab
Finally, add entry in fstab# /etc/fstab
/mnt/swap_file.swap none swap sw 0 0
After you have swap file added. Now you can back to [SOLVED] RAILS_ENV=production rake db:migrate, and it should complete without being killed.