Skip to content

Installing nodeStorage on Heroku

Marco Fabbri edited this page Jan 21, 2015 · 5 revisions

Here's a hopefully brief how to get nodeStorage running on Heroku. It builds on the great guide [Installing Storage on a VPS](Installing Storage on a VPS).

This how to requires a basic understanding of git, shell and node.js and will get you through setting up the required services to run nodeStorage with:

  • Amazon Web Services
  • Twitter API
  • Heroku

Amazon Web Services

  1. Get AmazonAccessKey and AmazonSecretAccessKey following the steps in Amazon API Keys
  2. Setup public and private Amazon S3 buckets as described in Amazon S3 Buckets

Twitter API

Follow the steps in Twitter API Keys and get TwitterConsumerKey and TwitterConsumerSecret.

#Heroku

If you don't have an account yet, you can easily signup. You can start running nodeStorage with a the Free Account.

Once you have signed up make sure to go through the Getting Started with Node.js on Heroku. Make sure to install and login with the Heroku Toolbelt as in Set up and understand how to prepare and deploy the app.

NOTE: once you are done, get rid of the getting started app from Heroku Dashboard: click on the app name in the Dashboard, got to the Settings tab, scroll to the bottom and click on the big red scary Delete app... button.

Ok, now let's setup nodeStorage.

First, clone the repo from github, from a terminal:

git clone https://github.com/scripting/nodeStorage
cd nodeStorage

Then create the app and rename it, the name will be used to access your app in https://.herokuapp.com where is the name you selected. Let's say we call the app my-nodestorage. From the terminal, as left in the previous step:

heroku create
heroku apps:rename my-nodestorage

Then configure the parameters collected in the previous steps (i.e. TwitterConsumerKey, TwitterConsumerSecret and so on).

heroku config:set twitterConsumerKey=TwitterConsumerKey
heroku config:set twitterConsumerSecret=TwitterConsumerSecret
heroku config:set AWS_ACCESS_KEY_ID=AmazonAccessKey
heroku config:set AWS_SECRET_ACCESS_KEY=AmazonSecretAccessKey
heroku config:set AWS_REGION=yourS3AWSRegion
heroku config:set s3Path=/public.example.com/
heroku config:set s3PrivatePath=/private.example.com/
heroku config:set myDomain=my-nodestorage.herokuapp.com
heroku config:set TZ=America/Chicago

Finally deploy the app

heroku deploy
heroku ps:scale web=1

The last command ensures that at least one instance of the app is running.

You can verify your very own nodeStorage instance is deployed and running from the terminal:

heroku open

It will display a page the following text:

"/" is not one of the endpoints defined by this server.

It's fine, if you navigate to /stats, i.e. in the example http://my-nodestorage.herokuapp.com/stats you will see some statistics on your nodeStorage instance like:

{
    "today": "2015-01-20T16:18:24.450Z",
    "ctHits": 19,
    "ctHitsThisRun": 3,
    "ctHitsToday": 10,
    "ctTweets": 0,
    "ctTweetsThisRun": 0,
    "ctTweetsToday": 0,
    "ctTweetErrors": 0,
    "whenServerStart": "2015-01-20T18:04:25.713Z",
    "ctHoursServerUp": 0.2977577777777778,
    "ctServerStarts": 4,
    "version": "0.62",
    "ctFileSaves": 0,
    "ctLongPollPushes": 0,
    "ctLongPollPops": 0,
    "ctLongPollTimeouts": 0,
    "ctLongPollUpdates": 0,
    "ctCurrentLongPolls": 0,
    "ctLongPollsToday": 0,
    "recentTweets": []
}

Now that your very own nodeStorage is up and running it's time to move on and build some cool app that runs in the browser like MacWrite.

NOTE: If you want to test your nodeStorage with the MacWrite example project just remember to change the setting for urlTwitterServer in the global config var appConsts at the beginning of macwrite.js (in our example it would have been "https://my-nodestorage.herokuapp.com/").

Clone this wiki locally