Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I update a single source file on Heroku without recompiling the slug?

I'm working on a rails project that's being hosted on Heroku. I'm wondering if it's possible to update one file, without restarting the app.

Why. I have a bug, but I can't track it down. It works perfectly on my local system, but it seems to stop mid way through processing on heroku.

As there are no break points, I'm scattering status updates in the code. (to be removed later) But adding one line of code to a rails app is like a five minute process.

  1. change file
  2. stage file to git
  3. commit file
  4. push git (all the above is quite fast)
  5. wait for heroku to pull down the app, do what looks like a gem install, or at least a gem update.
  6. change a few files to reflect the local url
  7. start up the service again.

Is there a way to push the git without running all those other things? Perhaps a special parameter to add to the push?



A further annoyance is that my git now has a bunch of check-ins that I don't want my co-workers to see. I'm targeting a my own non-production instance of heroku (testing only) and there's no reason to include all these attempts in the global source control.
like image 997
baash05 Avatar asked Jul 10 '12 01:07

baash05


People also ask

Can we edit code in Heroku?

You cant edit your files online and expect them to be in sync with your own repository , it defeats the purpose of using a vcs , as soon as you push an new version your online edited files will be deleted.

Can I redeploy on Heroku?

It turns out there is a neat plugin for Heroku called heroku release retry that lets you retry the last deploy without resorting to adding bad commits to your repository. Show activity on this post. You can run heroku restart --app app_name and you are good to go.


1 Answers

There's a good reason as to why it's not possible. When you push to Heroku, they produce a 'slug' of your application (https://devcenter.heroku.com/articles/slug-compiler). To provide the massive scalability that Heroku provides this slug is read only so that it can be spun up on multiple dynos which are likely to be distributed across many different physical machines. Each of these dynos runs a separate instance of your application whilst the routing mesh ensures that requests to your application goes to the correct dynos.

Now consider what would occur if any of these instances were writeable, if you're running 5 dynos you'd have your application running on 5 seperate instances - if a file is written how is it then distributed across of your running dynos? Yes, Heroku could have considered some kind of shared file system for running applications out of but that's complicated. By making the file system read only (https://devcenter.heroku.com/articles/read-only-filesystem) this problem is alleviated.

If you've built an app and deployed to Heroku but forgotten to use S3 type peristant storage your application will let you upload files to it (via Paperclip of such like in the Ruby world) but that uploaded asset will only exist on the dyno that received it and will then be lost when new code is deployed or the application restarted as the dyno receives the latest code from the slug.

If you're debugging against Heroku don't forget you've got the usual git arsenal available, git commit --amend. Alternatively work in a branch and deploy that to directly to Heroku (git push heroku <yourbranchname>:master) then when you've isolated the problem rebase (http://git-scm.com/book/en/Git-Branching-Rebasing) your branch onto master squashing any commits you no longer need.

like image 169
John Beynon Avatar answered Oct 11 '22 15:10

John Beynon