Please do not feed picture
Even though most of my daily news come already through Twitter, for some publishers I still prefer to use RSS readers. Until now I have been a long-time user of Reader by Google. And yes, I was disappointed by their decision to abandon the project. However, when you are consuming a free services, you've got to be okay with the possibility something like this may happen. Business goals for companies are changing all the time.

However I came upon a great alternative called Stringer. It's a self-hosted anti-social RSS reader. I like both of those aspects. Social reading was never suitable and never actually worked for me. And with the sharing aspect, when there is something worth sharing, I use the tweet button.

The self-hosted part is also nice. I can now run it for free on OpenShift, and there is no lock-in with OpenShift so I can just move to some other provider. All I need to do is take my data and ruby source code and run it on any other Ruby hosting provider (even my own machine).

Enough words, let's deploy

Spinning up the application

You will need a free OpenShift account. For more information use the "Get Started" page.

First, create new OpenShift application of Ruby-1.9 and Postgresql type and enter the directory

rhc app create feeds ruby-1.9 postgresql-8.4
cd feeds

then pull the code into the repository cloned from OpenShift

git remote add upstream git://github.com/swanson/stringer.git
git pull -s recursive -X theirs upstream master

Now the application code is in place, we can put some automation and configuration in the right places.

We will need to enable migrations for the application by just uncommenting 3 special lines in your repository in a file called .openshift/action_hooks/deploy. It's also required to rename the RAILS_ENV environment variable to RACK_ENV.

Update: with the recent change to cartridges, the action_hook file is not there by default. Please, create a new file and add these three lines in it.

pushd ${OPENSHIFT_REPO_DIR} > /dev/null
bundle exec rake db:migrate RACK_ENV="production"
popd > /dev/null

(Stringer is based on Sinatra therefore a Rails configuration is not well-suited)

Next we need to generate secret for the application, for example by running openssl rand -hex 20 and add it to a file called .openshift/action_hooks/pre_start_ruby-1.9 . Add a like like this to export the environment variable for the application

Update: as with the previous, create new files as the file is not there by default anymore.

export SECRET_TOKEN="your secret"

Update: On Unix-like systems (Linux, MacOSX, etc.) ensure your hooks are executable

chmod +x .openshift/action_hooks/*

Now let's configure the database server. Open file config/database.yml and add your production configuration. OpenShift uses environment variables to push the information into the application, so we will use those.

production:
adapter: postgresql
database: <%= ENV["OPENSHIFT_APP_NAME"] %>
host: <%= ENV["OPENSHIFT_POSTGRESQL_DB_HOST"] %>
port: <%= ENV["OPENSHIFT_POSTGRESQL_DB_PORT"] %>
username: <%= ENV["OPENSHIFT_POSTGRESQL_DB_USERNAME"] %>
password: <%= ENV["OPENSHIFT_POSTGRESQL_DB_PASSWORD"] %>

As a final step, let's commit and push to OpenShift

git add .
git commit -m "Deploy"
git push

Now you can go to your new application and create new password. It will also allow you to import feeds from Google Reader.

Feed fetcher

Stringer has one more standalone component - automatic feeds fetcher. To enable that let's add new cron cartridge to our application for scheduling

rhc cartridge add cron -a feeds

and create a new task just by creating a new executable file .openshift/cron/hourly/fetch_feeds in your repository with this content

pushd ${OPENSHIFT_REPO_DIR} > /dev/null
bundle exec rake fetch_feeds RACK_ENV="production"
popd > /dev/null

make it executable by running (this is not needed on Windows)

chmod +x .openshift/cron/hourly/fetch_feeds

Once again - commit your changes and push them to OpenShift to deploy the application. Your installation of Stringer will now fetch feeds automatically every hour.

Conclusion

Google Reader was a great tool, but Stringer seems to be a solid alternative. Simple and intuitive interface with all the features you would expect from such a tool. As a bonus, for me, there is no clutter with all the social nonsenses and is self-hosted with me again in control.

What's Next?


Categories

PostgreSQL, OpenShift Online

< Back to the blog