Step by step
Step by step
durable.js relies on MongoDb version 2.4. I have tested the 64 bit version for windows and mac. To get the database started follow the simple steps:
- Download mongoDb for Windows or mongoDb for Mac.
- Extract the zip\tgz package into a directory (for example, c:\mongo).
- Start a command prompt in admin mode in Windows or the terminal in Mac.
- Goto mongoDb bin directory (c:\mongo\bin) and create a /data/db directory:
mkdir /data/db
. - From the mongoDb bin directory run the command
mongod.exe
in Windows,./mongod
in Mac. - Congratulations! Your database is now up and running.
For more information go to: http://www.mongodb.org/downloads.
durable.js uses Node.js version 0.10.15. Getting node.js installed is very simple:
- Download node.js for Windows or node.js for Mac.
- Run the installer, don't fight it, just follow the instructions.
- The installer will set all the necessary environment variables, so you are ready to go.
For more information go to: http://nodejs.org/download.
Now that your database and web server are ready, let's write our first program:
-
Open a command prompt in admin mode in Windows or the terminal in Mac.
-
Create a directory for your app:
mkdir /firstapp
. -
In the new directory
npm install durable
(this will download durable.js and its dependencies) -
In that same directory create a test.js file using your favorite editor.
-
Type or copy and save the following code:
var d = require('durable');
d.run({
sequence: d.receive({ content: 'first' })
.continueWith(function (s) { s.firstContinue = true; })
.checkpoint('first') .receive({ content: 'second' }) .continueWith(function (s) { s.secondContinue = true; })
.checkpoint('second') });
...
6. In the command prompt or terminal type node test.js
.
7. Open the web browser and go to: http://localhost:5000/sequence/1/admin.html. The UI you see should be similar to this.
8. Type the message definition in the textbox at the bottom and click the 'Post Message' button.
{ "id":1, "content":"first" }
...
-
Install git
-
Install heroku toolbelt
-
Create a git repository
-
Write package.json
{ "name": "test", "version": "0.0.1", "dependencies": { "durable": "0.0.1" }, "engines": { "node": "0.8.x", "npm": "1.1.x" } }
...
5. procfile
web: node test.js
...
6. git push
7. heroku push
8. dyno start