asset:precompile hangs when run remotely.

3,526 views
Skip to first unread message

tim

unread,
Mar 13, 2012, 5:12:36 PM3/13/12
to Capistrano
I can precompile the assets using the rake task locally but when I
attempt to run it remotely it hangs. Looking at the log files it seems
to compile all the assets but hangs afterwards. Has anybody run into
this problem?

Cheers.

Lee Hambley

unread,
Mar 14, 2012, 4:27:06 AM3/14/12
to capis...@googlegroups.com
Tim,

Compiling assets on my server takes upwards of 5 minutes, it's possible your SSH connection is being HUP'ed in that time. (Locally (Mac) it takes ~90 seconds, I'm assuming the difference is connected to LibV8 being a slowpoke)

That's the best I can think of; debugging-wise, I'd be tempted to open another ssh session on the hosts that are playing up, and see what's happening, watch the list of logged in users, see if Cap is logging out, watch the sshd log for HUPs, and watch the process tree, and see what's going on with your assets.

- Lee
--
* You received this message because you are subscribed to the Google Groups "Capistrano" group.
* To post to this group, send email to capis...@googlegroups.com
* To unsubscribe from this group, send email to capistrano+...@googlegroups.com For more options, visit this group at http://groups.google.com/group/capistrano?hl=en

Tim Uckun

unread,
Mar 14, 2012, 4:39:35 PM3/14/12
to capis...@googlegroups.com
On Wed, Mar 14, 2012 at 9:27 PM, Lee Hambley <lee.h...@gmail.com> wrote:
> Tim,
>
> Compiling assets on my server takes upwards of 5 minutes, it's possible your
> SSH connection is being HUP'ed in that time. (Locally (Mac) it takes ~90
> seconds, I'm assuming the difference is connected to LibV8 being a slowpoke)

Wow five minutes? That's insane.

> That's the best I can think of; debugging-wise, I'd be tempted to open
> another ssh session on the hosts that are playing up, and see what's
> happening, watch the list of logged in users, see if Cap is logging out,
> watch the sshd log for HUPs, and watch the process tree, and see what's
> going on with your assets.
>

Well I looked at the log file and it really seems like the
pre-compilation done. That's the confusing thing for me. When I
compare the log output from my asset compilation and the servers it
looks the same but somehow the asset:precompile is not finished yet.

tim

unread,
Apr 3, 2012, 3:17:05 AM4/3/12
to capis...@googlegroups.com
Hey guys.

I am going to bump this post in the hopes that somebody else has run into this problem.

In a nutshell rake:precompile hangs on the production server but works fine on the local machine. Looking at the log file I can see that it has compiled all the assets twice and then has hung for some reason.

Any clues? I am not doing anything crazy or special. 

Rafa García

unread,
Apr 3, 2012, 8:24:09 AM4/3/12
to capis...@googlegroups.com
If the connection is blocked by this task for a long time maybe your sshd(or ssh client) configuration hang up the connection.

Could you try to play with ServerAliveInterval and ServerAliveCountMax (in ~/.ssh/config) ?

I'm not sure but you don't lose nothing with it :)

2012/4/3 tim <timu...@gmail.com>

--

javinto

unread,
Apr 3, 2012, 12:06:08 PM4/3/12
to Capistrano
I would recommend looking for another assets compilation app. I had
the same issue when Rails 3.1 came out and my provider underestimated
the impact of it. Finally they adjusted the compilation process where
I needed to use:
gem 'therubyracer'
gem 'execjs'

And now compilation just takes several seconds.


On 3 apr, 14:24, Rafa García <conta...@rafagarcia.net> wrote:
> If the connection is blocked by this task for a long time maybe your
> sshd(or ssh client) configuration hang up the connection.
>
> Could you try to play with ServerAliveInterval and ServerAliveCountMax (in
> ~/.ssh/config) ?
>
> I'm not sure but you don't lose nothing with it :)
>
> 2012/4/3 tim <timuc...@gmail.com>

Rob Hunter

unread,
Apr 3, 2012, 12:52:08 PM4/3/12
to capis...@googlegroups.com

If the server is Linux-based, `strace` is great for figuring out
what's going on with a "stuck" process.

$ strace -e file rake assets:precompile
... runs `rake assets:precompile`, printing out any time a file is
opened or checked

$ strace -e file,network,process rake assets:precompile
... the same as above, but also printing network process and subcommands run

$ strace -e file,process -f rake assets:precompile
... the -f parameter follows forks -- in case it's not `rake` but a
subshell that you're interested in

$ strace -p 1234
... connect to pid 1234 and start tracing


Solaris has `truss`, which provides similar capabilities but it uses
different parameters.


I hope that gives you a clue to what's going on!

--
Rob Hunter (@rjhunter)
Just Some Guy, ThoughtWorks

Tim Uckun

unread,
Apr 4, 2012, 8:43:51 PM4/4/12
to Capistrano
I have done more digging and it's not a capistrano problem, it's a
rails problem For some reason the thing that takes a few seconds on my
machine takes more than a half an hour on the server. I have seen the
following recipes on the web which don't work with the current version
of capistrano

task :precompile do
run_locally ("rake assets:clean && rake assets:precompile")
upload( "public/assets", "#{release_path}/public/assets", :via
=> :scp, :recursive => true)
end

This fails because it wants a FILES env variable.

%x{bundle exec rake assets:precompile}
%x{rsync --recursive --times --rsh=ssh --compress --human-
readable --progress public/assets #{user}@#{host}:#{shared_path}}
%x{bundle exec rake assets:clean}

this fails because it doesn't know what host is.

I like the rysnc idea. Can that be made to work. Is there a way to
specify "the current host you are deploying to"?


Tim Uckun

unread,
Apr 4, 2012, 11:54:12 PM4/4/12
to Capistrano
I did the following which seems to work well

task :precompile, :roles => :web, :except => { :no_release => true }
do
run_locally("rm -rf public/assets/*")
run_locally("bundle exec rake assets:precompile")
servers = find_servers_for_task(current_task)
port_option = port ? " -e 'ssh -p #{port}' " : ''
servers.each do |server|
run_locally("rsync --recursive --times --rsh=ssh --compress --
human-readable #{port_option} --progress public/assets #{user}
@#{server}:#{shared_path}")
end
end


On Apr 5, 12:43 pm, Tim Uckun <tim.uc...@digitaldialogue.com.au>
wrote:

Moritz Schepp

unread,
Oct 19, 2015, 3:57:15 PM10/19/15
to Capistrano
I just had this problem (I'm not using capistrano) and in fact on my dev machine it would work nice and quick but on the server it would compile the assets and then hang forever. However, after waiting for it to finish, doing it a second time is quick and painless. Turns out that assets:precompile also does a tmp:cache:clear which only had a lot to clean up on the production machine.

Lee Hambley

unread,
Oct 19, 2015, 4:01:43 PM10/19/15
to Capistrano
Good information, thank you for sharing. It's a shame that it hangs without printing any output, if it would Capistrano would normally print it.
--
You received this message because you are subscribed to the Google Groups "Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capistrano+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/capistrano/7299ee36-d442-46d3-8ce8-1dfa3c253a62%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages