In 2009 I wrote a tutorial called EC2 for Poets, and updated it in 2012. I wanted to see if it was possible to teach regular computer users to set up and run a server. I felt that setting up a server could be no more complex than installing and learning how to use PhotoShop (something I have never mastered) or a spreadsheet.

Lately I've become interested in Node.js. I've learned how to write Node apps, and have a couple of simple ones running, and doing things for me and some courageous users.

And the question comes up -- how easy is it to set up a Node server?

The answer -- pretty easy, once you know how to.

So that's what I'd like to do now. Tell you how to do it.

With the caveat that I've just learned myself, with the expert and patient guidance of a long-time friend -- Eric Kidd. He's really the author of these instructions, I've just tested them and written them down.

You're using a Mac, I hope

I'm writing these instructions assuming you're using a Mac. It'll work similarly if you're using Linux, and I'm told there are some small differences if you're on Windows. I haven't tried it there.

Before starting

Create an account on heroku.com. In this regard it works like every other site, so I won't insult your intelligence by giving you detailed instructions for this part of the experiment.

Launch Terminal

In the Applications folder, there's a program called Terminal. Launch it. This is how you communicate with Heroku from your computer.

Install the Heroku toolbelt. Follow the instructions on the Heroku site.

Get my example app

I have a simple Node app called fargoPublisher. Download the project using this link. Unzip it. Change the name of the folder to fargoPublisher.

It doesn't matter where you put the folder, but we're going to have to refer to it later, so let's assume you put it on a disk named myworld.

Name your app

You need to come up with a unique name for your app, one that isn't used elsewhere in Heroku. It could be a little tricky, but you'll get an error message if you choose one that someone else is using. In the instructions below, I use the name purplenutter.

Magic incantations

Type these commands in the Terminal app, exactly as they appear here.

cd /myworld/fargopublisher

git init

git add package.json publisher.js

git commit -m "Initial source code"

heroku create purplenutter

git push heroku master

Did it work?

If it worked you should get a confirmation message from Heroku.

And your app, if it was named purplenutter, will be at http://purplenutter.herokuapp.com/.

Setting environment variables

There's one more step to getting the app running for real, if you want to, you have to set a couple of environment variables so that it can write to your S3 bucket instead of mine (assuming you have an Amazon account).

There are four variables you have to set: the AWS access key ID, and secret access key, the path to a folder in one of your buckets, and a domain name. To test out whether the app is running you don't have to supply real values, just something -- so the program can access them.

You set an environment variable like this:

heroku config:set AWS_ACCESS_KEY_ID=OHBEAUTIFUL --app purplenutter 

heroku config:set AWS_SECRET_ACCESS_KEY=FORSPACIOUSSKIES --app purplenutter 

heroku config:set fpHostingPath=/mybucket/users/ --app purplenutter 

heroku config:set fpDataPath=/mybucket/data/ --app purplenutter 

heroku config:set fpDomain=helloworld.com --app purplenutter 

Enter each of these commands into the Terminal app.

Each time you do it, your app will restart.

The proof it's running

Enter this into your browser, substituting the name of your app:

http://purplenutter.herokuapp.com/version

You should get back a number, something like 0.59. If so -- it's running!

You should also visit your app on the Heroku site. To do so, go to the Apps page, and click on the link to your app. You're such a geek! A successful one!

What if you make a change?

No app is ever finished, you'll want to add features, fix bugs.

When you've made a change, here's the prayer you need to tell Heroku-san.

git commit -a -m "Update"

git push heroku master

It's free

It's really cool that Heroku will run this server for you for free, for as long as you want. If your service becomes popular then you have to pay them to run it. But as long as it's just for you and some friends it's free.

Amazon S3 and Heroku

I've been building my apps to work with Amazon S3 for storage. It think it's a really good combination. My apps store their state in S3 objects, which are fast and really cheap to store and serve. And I'm pretty sure Heroku runs in Amazon's cloud, so access is very fast.

Git and Heroku

Eric sent me an email after I got my app running, explaining how Git and Heroku work together. These are literally Eric's words, I just pasted them in here and formatted them.

Git stores your source code in a repository. This contains all your files, their history, your commit messages, etc.

Repositories come in two flavors:

  • Local repositories. These look like ordinary directories of source code, but they contain a hidden ".git" directory with all your history and metadata. For example, when we run "git init" in fargoCounters, it creates a directory "fargoCounters/.git" and fills it with various things.

  • Remote repositories. These are basically a bare version of your ".git" directory, without a surrounding directory full of source code. By convention, these are named something like "fargoCounters.git", and they typically live on a server somewhere. You can have any number of remote repositories: maybe none, maybe one on GitHub, maybe a bunch.

When you "commit" changes, they go into your local repository.

When you "push" changes, it takes the changes that were committed to your local repository and copies them to a remote repository. When you "pull" changes, you copy from a remote repository into your local repository. Using push and pull, you could move code around between several remote repositories, which is very useful for a team. For example, I could create my own fargoPublisher repository will a bunch of changes, and you could "pull" from my remote repository to your local repository, and then (if you like the changes), you could "push" them to your repositories on GitHub and Heroku.

Heroku basically acts like a magic remote repository for your app. You commit changes to your local repository, and push them to Heroku using 'git push heroku master'. But unlike a regular remote repository, when Heroku receives your changes, it automatically recompiles your app, deploys it to a server, and restarts your app using the new code.

Git is frankly a pain in the ass, but once you finally get used to it, it's pretty nice, because it makes it easy to share changes. And GitHub is excellent. In a perfect world, git would be easier to understand, but our world is definitely imperfect. And on the bright side, at least git is standard in the Node.js and Ruby communities, so you only need to figure it out once and then you can use it for all kinds of stuff. It's better to have once slightly ugly solution that everybody uses than to have 37 different solutions that lock in the users.

Questions?

That's what the comments section is for, below.

Happy Heroku-ing my new geek friend!

PS: One of the reasons I wanted to list all the steps was so we could shorten the list. I explained the process in this post.

02/06/14; 05:35:48 PM

I love movies. It hasn't been a lifelong thing for me, it started in 2002, when I had heart surgery and began a six-month recovery. I took a lot of Vicodin, and didn't do much more than watch movies for the months of June, July and August of 2002. It was then that I discovered Turner Classic Movies. I had cable service, but never had enough time to look through all the channels. Having nothing better to do, I watched movies. (BTW, that's not exactly true. These were also my first months as an ex-smoker.)

One of the great things about TCM is they have special months, focusing on one actor, or a period, or a style of movie, and cover it in great detail. August 2002 was Joan Crawford Month, and I watched every one of the movies they played. In her first talking movie, in 1929, she sang and danced and smiled, she was so cute and charming and young. In 1932, she played a girl stranded on a Pacific island, victimized by other people's morality in Rain. Also in 1932, in Grand Hotel, she plays a secretary who is seduced by a seedy old married dude. In 1939, she played a leading role in The Women, which had a cast of women only. No men. They talk about the men, fight over them, divorce them, remarry, all of that, without any men on screen or with lines. She plays the woman that all the other women hate. The beginning of the Crawford persona. In the 40s she developed into a business person in Mildred Pierce, and many other characters. I think her last great movie was What Ever Happened to Baby Jane?, with Bette Davis. In this movie, she's old, and kind of dumb, and a little sweet. At least that's how I remember it.

Joan Crawford had her accuser, her adopted daughter, who wrote a book called Mommie Dearest, which became a movie, with Faye Dunaway playing Joan Crawford. The book came out in 1978, the movie in 1981. Here's a piece in the NYT in 1998, which gives an idea of how it shook out, 20 years after the book came out.

I wasn't a Crawford fan when all that happened. I never would have looked if I hadn't been on my back in need of something to explore, to study, to occupy my mind while my body was healing. And I'm so glad I did.

Whether Crawford abused her daughter or not, to me, is not connected to her work as an actor. Abuse isn't something that exists in a vacuum. Who was the victim? I have no idea. Each generation tries to do the best they can, but the gifts of previous generations can be hard to overcome. Where does the blame start? And what if Crawford's daughter was taking advantage of her dead mother, who wasn't able to tell her side of it? If we want to stop abuse, imho, the best thing we can do is all of us become conscious and develop a deep sense of fairness, and practice it, systematically, and without passion. Step back and take a deep breath, and stop treating people as symbols, and you'll be doing a lot to stop abuse.

I didn't love all of Crawford's movies, but I loved enough of them. Same with Woody Allen. His early movies are funny, often deep, personal, and are just plain great story-telling and movie-making. I can't believe supposedly serious people hold Manhattan up as evidence of some kind of wrong-doing! It's a brilliant story, beautifully told. The young woman, played by Mariel Hemingway, provided a perfect foil for the childishness of the adults. She was kind, thoughtful, cared about herself. I thought she was a role model for how someone should conduct themselves in love. She gets the last word, and leaves Woody standing at the door of her apartment, realizing it's time for him to grow up. Now don't get confused about whose words are whose -- that's Woody Allen speaking through the young Ms Hemingway. He's talking about himself to himself. The critics, these are supposed to be smart people. Why don't they get this?

He made a series of great movies, but he hasn't made one, in my opinion, since Vicky Cristina Barcelona. The Paris movie -- what was that about? And the latest one, Blue Jasmine, was a imho a waste of time, even though many people loved it.

There's no doubt that Mia Farrow, his ex, is trying to destroy his legacy. She's been pretty open about it. In what way does that protect women against abuse? You can't heal your pain by using it to destroy. She isn't in a high moral position. She decided this should become a public issue. Okay, then her motives deserve a look too, as Christina Crawford's motives were examined after the publication of Mommie Dearest.

Woody Allen's art, no matter what his crimes, or how tarnished his name becomes, stands. It's no longer his or Farrow's -- it belongs to all of us, for perpetuity, like Joan Crawford's work. Some of it is human expression at its best. Other bits, not so much. But it's not Farrow's or Kristof's to dispose of. And we also have to consider the possibility that they are cynically using Allen, and the rest of us, for some purpose that's not good for anyone but them.

I've been told not to touch this, that there's danger here for me. That's exactly why I have to write about it. I've even been told this by journalists! I guess that's how powerful the Internet shaming machine is. Cross them, and they'll find a way to abuse you, even if all you did was question their motives.

PS: The Front -- a 1976 Allen movie -- is a cautionary tale for the era of Internet shaming we're entering.

02/06/14; 10:15:43 AM

Last built: Fri, Mar 14, 2014 at 12:29 PM

By Dave Winer, Thursday, February 6, 2014 at 10:15 AM.