syntaxhighlighter

Tuesday, August 28, 2012

Init script - express-example/sqlite

I've been reading in the Express Forum about deploying Node.js applications and found some interesting points of view about that. My proposal is to deploy using Capistrano. I hope to comment about it in this space soon.

The thing that takes me to this space now is related to init scripts... Some days ago I was "fighting" against Pentaho BI Server init scripts, and based on my previous work, I propose the following script (init.d/sqlite) for Node.js applications. For installing, you need to change the following variables:

SQLITEAPP_DIR="/home/rodolfo/workspace/express-examples/sqlite"
SQLITEAPP_LOG="$SQLITEAPP_DIR/log/sqlite.log"

After changing that variables to the root directory where you have the Express App, and where you want to leave logs, can just start or stop the server like this:

$ bash init.d/sqlite start
$ bash init.d/sqlite stop

If you want to include the script into system init.d scripts (for -maybe- adding them later to rcX.d scripts) can do the following:

$ chmod +x init.d/sqlite
$ sudo ln -s init.d/sqlite /etc/init.d/sqlite-express-example

Now for starting and stopping:

$ sudo /etc/init.d/sqlite-express-example start
$ sudo /etc/init.d/sqlite-express-example stop

NOTE: As you can see, my script has the name of the app, that's because I'm assuming one app per Node.js instance, but if you're going to have only one instance for all apps, can rename all variables and the script to something related to Node.js.

ERRATUM: Is obvious that the name sqlite for the script is a very bad choice. Why I put that name? Nevermind... You can easily change it.

No comments:

Post a Comment