The rest of this series can be found here.
Setting up a Public Instance
Today, I’m working on setting up a public instance of this app, since must apps aren’t built just to run on the dev’s local computer. I initially tried running on the server I host several other sites on, but it’s a shared host running Ruby 1.8.7 and Rails 2.3.18, so it’s significantly behind current, and I’m unable to update it.
I could easily run on AWS, Google Cloud, etc., but since this is mainly a self-educational project, I don’t want to pour money into keeping a server running just to host it.
I found several services that host a couple of (small) free apps, and decided to try Red Hat’s OpenShift service. Their free tier lets you host up to 3 apps, and includes everything I need for this.
Initially, I tried setting up the app through OpenShift’s web service, and pulling in the existing GitHub repo. No matter what I tried, however, I ran into errors. I eventually ended up creating a new app from scratch using their client tools:
$ rhc app-create checklist ruby-2.0
I tried for a while to figure out how to use the new OpenShift app, add my code to it, and deploy, but eventually gave up as I was getting nowhere and spending too much time on it.
Heroku also lets you run a free dyno. I signed up for their service and went through the getting started guide.
- Installed their command-line tools
- `$ heroku create app-name` set up a new app
- I had to switch over from SQLite3 to PostgreSQL (see this article)
- Had to install PostgreSQL first:
- `$ brew install postgresql`
- `$ ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents`
- `$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist`
- Then continued with the database switch
- `$ git push heroku master` is all it takes to go live
But…something went wrong. I’m being told to check my application logs. Thankfully, Heroku is much more helpful than OpenShift was:
$ heroku logs --tail.
I also didn’t realize that I needed to run
$ heroku run rake db:migrate to get set up…duh. Finally…the app is up and running publicly.
I also added support for styling overdue items and sorting the list by completed status and then due date
Whew…seems like deploying a Rails app is a bit more complicated than a PHP site (including WordPress), though it’s been so long since I started with those types of sites that I’ve forgotten the learning curve.
Next up: setting up user accounts so everybody won’t start using my app and get all their todo items mixed up with each other’s…
The current code can be found here.