background preloader

Nodejs

Facebook Twitter

Sails.js | Realtime MVC Framework for Node.js. Running a Node.js Server as a Service Using Forever. There are a wide range of methods to set up a Node.js process as a service on Linux, with little consensus on a standard at this point. That's fine - Node.js is still a long way away from staid maturity and the era in a technology's development in which people settle on the two or three standard ways of solving a given problem. Here, I'll outline one of my presently preferred ways of setting up a Node.js server as a service on Linux, using Forever, an init.d script and some tailoring of the server application itself. The chief advantage of this method is that it allows for a graceful shutdown rather than just killing the process.

For later arrivals: note that this was originally written back in the archaic days of Node.js 0.4.* versions. The world changes! Some fixes to the original post were provided in January 2012 by Ben Atkin, and much appreciated. Further updates were made in July 2012. Install Node.js on Linux Now switch to the newly created node user: Tailor Your Node.js Application. Npm-gh. A simple npm bash wrapper, to use GitHub as a light-weight npm registry for publishing.

Why? I wanted: A private NPM registry,which was easily accessible by GitHub teams and users,who already had access to my private GitHub repos,but did not necessarily have access to my corporate intranet / vpn. I did not want: To have to maintain a private NPM registry on a public / hosted server.To have individual GitHub repos for each npm package.To spend the time to modify an npm fork. I don't care about: Having a web-based search-able, browse-able interface; GitHub is good enough for me.The unsightly git output when npm-gh publishes to a repo. First of all, you'll need npm. Then at a command-line: npm install -g git: Yep, that's right, npm-gh uses its own repo as a GitHub-backed public npm registry for itself. I may also publish on npmjs.org. In your package.json you need the following: If any of the above properties do not exist, or if you invoked npm-gh in any other way, npm is called instead.

Notes. How to create a private npm.js repository by Tom Gallacher. Or so I thought. I was going to do some development on my local machine, so I fired up npm install <packagename>. Unfortunately, due to a npmjs.org outage, it was not possible for me to get on with my work. So I did what any driven developer would do; I set up a CouchDB replica of npmjs.org. Next time this happens I will be prepared! As this npmjs.org replica is hosted in the same datacenter as we deploy most of our sites to, it enables a super speedy deployment to testing.

How do we go about this you ask? Installing CouchDB Note: These instruction are geared towards Ubuntu 12.04 LTS. Install the required packages: sudo apt-get install build-essential autoconf automake libtool erlang libicu-dev libmozjs-dev libcurl4-openssl-dev Download CouchDB 1.2: wget Extract, and relax: tar xfv apache-couchdb-1.2.0.tar.gz Now time to compile: cd apache-couchdb-1.2.0 . Sweet! User added, now permissions: Go! Node.ci: Node.js continuous integration. Deploying node.js apps by Ben Gourley. Here at Clock, long gone are the days of FTP uploads to put a site live. We use deployment tools to automate the process, which have the advantage of being faster, while reducing the chance of human error. I'm delving into node.js development, for which I've set up my own deployment and hosting. Here's my situation: I use my local machine for developmentI have a remote server with SSH access for testing and productionI'm using git for source controlnode and npm are installed locally and remotely And here are my objectives: Encapsulate deployment process into single git push commandHost multiple apps on a single serverHave multiple instances of each app for testing and production Read on and I'll take you through the different aspects of my solution.

Git When you initialise a git repository, it creates a directory called hooks. The system will assume that your post-receive is bash. On your server, initialise an empty, bare repository like so: Here is what we want our post-receive script to do: Node.js - Can I write npm package in coffeescript. Node.js.

Debugging

Index. Server Side JS Framework. Is NodeJS Wrong ? - Nicolas Cannasse Blog. NodeJS is pretty popular these days, so I took some time to have a in-depth look at it and analyze the pro/cons of using it against another server-side technology. The first issue I can see is not technical : you have to rewrite all your programs and libraries by passing callback methods. This is a bit annoying since if you want to make three async requests you have to write the following : async1(function(result1) { async2(function(result2) { async3(function(result3) { }); }); }) You also have to adopt the same style as soon as you make a regular function call that will itself make an async call.

There is one possibility however to convert this code into the following : var result1 = async1(); var result2 = async2(); var result3 = async3(); This involves using Continuation Passing Style transformation (CPS). Once the syntax issues are solved, let's see how NodeJS is implemented : NodeJS has a single event-loop thread that waits for I/O on sockets and files. Node.js. How To Node - NodeJS.