Search code examples
ruby-on-railsrubygitheroku

Git push Heroku master takes forever


I'm using a VM based on Ubuntu 12.04 (ruby 1.9.2p290 and rails 3.1.0) and my app work perfectly on local. I'm using Git and when I try to git push heroku master it doesn't work. I get:

Counting objects: 435, done. Compressing objects: 100% (215/215), done. Writing objects: 100% (435/435), 73.35 KiB, done. Total 435 (delta 171), reused 435 (delta 171)

And it never finish, so it doesn't push anything to Heroku. The terminal standby forever.

Operative System information:

jobs
[1]+  Running                 git push heroku master &

ps -x
PID TTY      STAT   TIME COMMAND
1078 ?        Ssl    0:00 gnome-session --session=ubuntu
1135 ?        Sl     0:00 /usr/bin/VBoxClient --clipboard
1147 ?        Sl     0:00 /usr/bin/VBoxClient --display
1154 ?        Sl     0:00 /usr/bin/VBoxClient --seamless
1162 ?        Sl     0:19 /usr/bin/VBoxClient --draganddrop
1167 ?        Ss     0:00 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-s
1171 ?        S      0:00 /usr/bin/dbus-launch --exit-with-session gnome-sessio
1172 ?        Ss     0:01 //bin/dbus-daemon --fork --print-pid 5 --print-addres
1246 ?        Sl     0:00 /usr/bin/gnome-keyring-daemon --start --components=se
1250 ?        Sl     0:02 /usr/lib/gnome-settings-daemon/gnome-settings-daemon
1329 ?        S      0:00 /usr/lib/gvfs/gvfsd
1334 ?        Sl     0:00 /usr/lib/gvfs//gvfs-fuse-daemon -f /home/ubuntu/.gvfs
1401 ?        Sl     0:03 metacity
1417 ?        S      0:00 /usr/lib/i386-linux-gnu/gconf/gconfd-2
1421 ?        S<l    0:01 /usr/bin/pulseaudio --start --log-target=syslog
1426 ?        Sl     0:01 unity-2d-panel
1427 ?        Sl     0:07 unity-2d-shell
1430 ?        S      0:00 /usr/lib/pulseaudio/pulse/gconf-helper
1447 ?        Sl     0:01 /usr/lib/bamf/bamfdaemon
1450 ?        Sl     0:00 /usr/lib/gnome-settings-daemon/gnome-fallback-mount-h
1453 ?        Sl     0:02 nautilus -n
1455 ?        Sl     0:00 /usr/lib/policykit-1-gnome/polkit-gnome-authenticatio
1457 ?        Sl     0:00 bluetooth-applet
1468 ?        Sl     0:00 nm-applet
1482 ?        S      0:00 /usr/lib/gvfs/gvfs-gdu-volume-monitor
1500 ?        Sl     0:00 /usr/lib/gvfs/gvfs-afc-volume-monitor
1504 ?        S      0:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
1518 ?        S      0:00 /usr/lib/gvfs/gvfsd-trash --spawner :1.9 /org/gtk/gvf
1521 ?        Sl     0:01 /usr/lib/unity/unity-panel-service
1523 ?        Sl     0:00 /usr/lib/dconf/dconf-service
1539 ?        Sl     0:00 /usr/lib/indicator-datetime/indicator-datetime-servic
1541 ?        Sl     0:00 /usr/lib/indicator-printers/indicator-printers-servic
1543 ?        Sl     0:00 /usr/lib/indicator-messages/indicator-messages-servic
1545 ?        Sl     0:00 /usr/lib/indicator-session/indicator-session-service
1547 ?        Sl     0:00 /usr/lib/indicator-application/indicator-application-
1549 ?        Sl     0:00 /usr/lib/indicator-sound/indicator-sound-service
1574 ?        S      0:00 /usr/lib/geoclue/geoclue-master
1591 ?        S      0:00 /usr/lib/ubuntu-geoip/ubuntu-geoip-provider
1597 ?        Sl     0:00 /usr/lib/gnome-disk-utility/gdu-notification-daemon
1603 ?        S      0:00 /usr/lib/gvfs/gvfsd-metadata
1609 ?        Sl     0:00 /usr/lib/indicator-appmenu/hud-service
1620 ?        Sl     0:00 /usr/lib/unity-lens-applications/unity-applications-d
1622 ?        Sl     0:00 /usr/lib/unity-lens-files/unity-files-daemon
1624 ?        Sl     0:00 /usr/lib/unity-lens-music/unity-music-daemon
1626 ?        Sl     0:00 /usr/bin/python /usr/lib/unity-lens-video/unity-lens-
1653 ?        Sl     0:00 /usr/bin/zeitgeist-daemon
1661 ?        Sl     0:00 telepathy-indicator
1668 ?        Sl     0:00 /usr/lib/zeitgeist/zeitgeist-fts
1672 ?        Sl     0:00 zeitgeist-datahub
1676 ?        S      0:00 /bin/cat
1682 ?        Sl     0:00 /usr/lib/telepathy/mission-control-5
1701 ?        Sl     0:00 gnome-screensaver
1703 ?        Sl     0:00 /usr/bin/python /usr/lib/unity-scope-video-remote/uni
1728 ?        Sl     0:05 gnome-terminal
1734 ?        S      0:00 gnome-pty-helper
1738 pts/2    Ss     0:00 bash
1796 ?        Sl     0:00 update-notifier
1954 pts/2    S      0:00 git push heroku master
1955 pts/2    S      0:00 ssh git@heroku.com git-receive-pack 'polar-island-471
1959 pts/2    R+     0:00 ps -x

Solution

  • There are many reasons why your push to Heroku can timeout. In my experience, the most common reason is due to site size, and by site size, I mean 3 things: the size of your Git repo, the size of your site that gets pushed to Heroku (Git repo - ignored files), and the size of the gems you use. Heroku is not particularly robust when it comes to accommodating big sites (or long running processes, for that matter) and if you get too big, you can cause your push to hang / timeout and intermittently too, which can be perplexing.

    .git folder I have had the site get unexplainably large and saw that over time my .git folder in the root of the project had grown to 600mb. Thank goodness I noticed a warning in the Heroku deploy chatter that warned me that my Git repo was too large. Anyway, since that folder is managed by Git behind the scenes, I ended up starting a fresh Git repo and moving my code over to it, which shrunk my site by 90%.

    .slugignore Another pitfall that caused my site to become large enough to timeout was allowing things like logs, my temp directory, and my Solr indexing directory to be included in the project. After I excluded all of those folders in my .slugignore file, pushing became very fast. And yes, you could get the same basic effect using .gitignore, but there are some things that I like to manage through Git, but ignore when pushing to Heroku. That's when the .slugignore comes in handy.

    gems By completing the steps above, I reduced my site to a reasonable size, but still had occasional timeouts. Then I realized that gems contribute to your site size too. So I removed a handful of unused gems from my gemfile, and I was able to reduce my slug compile time from 900+ seconds to 250 seconds and my overall deployment time from 15+ minutes with frequent timeouts to under 10 minutes. What a relief to not have to wait so long for each deploy and risk timing out half the time.

    Depending on your particular setup, any or all of these factors can really hurt you. In my case I was doing everything wrong. However, even if you are not timing out, you may still want to prune your site as much as possible to cut down your deployment time.

    how to make Heroku not suck http://www.stormconsultancy.co.uk/blog/development/6-ways-to-get-more-bang-for-your-heroku-buck-while-making-your-rails-site-super-snappy/