Capistrano 3 assets:precompile takes hours. Stops

2019-02-21 21:20发布

问题:

Just as it says, I can't get capistrano 3 to do assets:precompile correctly. Even after hours, it still says writing to the .css file on the server.

UPDATE:

I was playing around and I tried a m1.medium. Same thing happened when it got to a certain point it simply stopped precompiling. Not errors are thrown, the cursor simply flashes.

It looks like it is still working, as it just says:

I, [2013-12-31T01:18:45.210416 #31413] INFO -- : Writing /var/www/app/releases/20131231011622/public/assets/application-998b176a776d6aff56fce8af9ca0d861.css

When I look at the cpu usage from any instance It looks like this:

It seems like the process is done, but it isn't. I created a fake application from scratch and it uploads perfectly with the same capistrano settings. I am using ckeditor, bootstrap-sass and a custom engine if that makes a difference.

If I need to show any other files I would be happy to add them here.

Thanks

Update 2 I got it to work on m1.medium instances, but it still fails on m1.small or t1.micro instances. So I assume it is with the ssh.

回答1:

I had a similar issue where Capistrano 3 freezes on assets:precompile.

For me it turned out that it was an SSH problem due to the prolonged time it takes to precompile assets on production! Especially if the server memory and CPU specs are not too high.

Although my connection to the production server was pretty fast and reliable, it seemed that my SSH client just gave up reading output from SSHD server after a certain amount of time.

The Fix

Add the following in /etc/ssh/sshd_config on production server to keep connection with SSH client alive:

ClientAliveInterval 30
ClientAliveCountMax 10

This fixed the issue and now Capistrano 3 completes deployment with no problems.



回答2:

  1. Is this a Windows instance? Windows instances by default use the IE6 Javascript/CSS engine which is PATHETICALLY SLOW and accurately reflects the problem that you are facing.

  2. If it is a Linux instance, try adding the uglifier and therubyracer gems in your Gemfile, and also make sure to install Firefox/libv8