arzumy md short notes on small discoveries

Aspen Shutdown, Serve Static HTML From Cedar And run:detached

27 November 2012

Heroku is shutting down the Aspen stack effective November 26, 2012. I have few apps still running on Aspen, but most of them are trial apps, so I never bothered to migrate to Cedar. Except, today I realized Codelovr’s site was down. It was still on Aspen!

I quickly pulled down the code. After quick check, it was a rails app during the early days. But it was serving just a single html file with one stylesheet. There’s no reason why we should continue with that. I decided to just serve static html directly. A quick search showed there are multiple ways to serve static html on Cedar stack. I chose to use Apache to serve it. I got the tutorial from http://kennethreitz.com/static-sites-on-heroku-cedar.html

First we must make sure index.php exists. I copied my index.html to index.php. I’ve copied my html and stylesheet to new directory.

  cp index.{html,php}

To understand why we need index.php, we can have a look at how heroku-buildpack-php detect it. The code is here https://github.com/heroku/heroku-buildpack-php/blob/master/bin/detect. The exact line is

  if [ -f $1/index.php ]; then

Then we turn off php engine

  echo 'php_flag engine off' > .htaccess

Commit everything, create new Cedar stack and push!

  git init . 
  git add .
  git commit -am 'initial commit'
  heroku apps:create 
  git push heroku
  heroku open

If everything is cool we can delete the Aspen app and add back our custom domain to the new Cedar app.

Another thing I learned today is how to run task in background. There are places where port 5000 is blocked and running heroku run rake db:migrate always ended up with time out connecting to process. To bypass that, we just run it in background with run:detached

  heroku run:detached rake db:migrate
  
  Output:
  Running `rake db:migrate` detached... up, run.4271
  Use `heroku logs -p run.4271` to view the output.
  
  heroku logs -p run.4271 # To view log

You can read more here https://devcenter.heroku.com/articles/oneoff-admin-ps#running-tasks-in-background

arzumy md, CTO at Fave and BillPlz.

https://www.facebook.com/arzumy
https://my.linkedin.com/in/arzumy
https://www.google.com/search?q=arzumy