Size: 2121
Comment: Added more to test install
|
← Revision 4 as of 2014-05-18 02:50:36 ⇥
Size: 3489
Comment: Finished it up hopefully
|
Deletions are marked like this. | Additions are marked like this. |
Line 13: | Line 13: |
{{{#!highlight bash | {{{ |
Line 20: | Line 20: |
{{{#!highlight bash | {{{ |
Line 27: | Line 27: |
{{{#!highlight bash | {{{ |
Line 34: | Line 34: |
{{{#!highlight bash | {{{ |
Line 53: | Line 53: |
Configure your domain, modelling [[DomTool/Examples#mod_proxy|this example]]. This will foward from requests to your domain on navajos to the port that you requested on bog. |
Configure your domain, modelling [[DomTool/Examples#mod_proxy|this example]]. This will foward requests to your domain to the port that you requested on bog. Give it a test run {{{ mcarberry@bog:~/public_web/sitename$ ./nodejs/bin/node hello_world.js }}} If it works, when you visit your domain name you should see the Hello Node.js message. === Write a Script to Start the Server === Here's a script I use to start my Node.js server running Ghost. You'll need to use k5start (as I do) in order to make sure your server is able to maintain access to AFS. You should be able to modify this script to your needs with not too much effort. {{{#!highlight bash #!/bin/bash HOME=/afs/hcoop.net/user/m/mc/mcarberry GHOSTROOT=$HOME/public_web/ghost/ghost-app NODEROOT=$HOME/public_web/ghost/nodejs NODE=$NODEROOT/bin/node PIDFILE=$GHOSTROOT/ghost.pid K5START="k5start -qtUf /etc/keytabs/user.daemon/mcarberry" cd $GHOSTROOT NODE_CONFIG_DIR=$GHOSTROOT if (test -f $PIDFILE); then echo "PID File exists..." PID=`cat $PIDFILE 2> /dev/null` echo "Is previous server still running" kill -0 $PID 2> /dev/null if (test $? -ne 0); then echo "Nope, starting server" $K5START -b -c $PIDFILE -- $NODE $GHOSTROOT/index.js else echo "Yes, no need to start server" exit 0 fi else echo "Starting server" $K5START -b -c $PIDFILE -- $NODE $GHOSTROOT/index.js fi }}} === Add a Reboot Rule to Crontab === Request crontab access throught the portal, and set a rule such that your script will be run in the event of bog being rebooted. |
What is Node.js
- Node.js is an application server based off of Google's V8 Javascript Engine. Quite a few popular frameworks have popped up around Node.js such as AngularJS and Backbone.js.
How
Request a port
Request a ProxiedServer port on bog as described in FirewallRules
Get Node.js
- Make a directory for your website
mcarberry@bog:~$ mkdir ~/public_web/sitename mcarberry@bog:~$ mkdir ~/public_web/sitename/nodejs mcarberry@bog:~$ cd ~/public_web/sitename
Download Node.jsmcarberry@bog:~/public_web/sitename$ wget http://nodejs.org/dist/v0.10.26/node-v0.10.26.tar.gz mcarberry@bog:~/public_web/sitename$ tar -xf node-v0.10.26.tar.gz mcarberry@bog:~/public_web/sitename$ cd node-v0.10.26/
Build Node.js
mcarberry@bog:~/public_web/sitename/node-v0.10.26$ ./configure mcarberry@bog:~/public_web/sitename/node-v0.10.26$ make mcarberry@bog:~/public_web/sitename/node-v0.10.26$ make install DESTDIR=~/public_web/sitename/nodejs
Cleanup Install Directorymcarberry@bog:~/public_web/sitename/node-v0.10.26$ cd ../nodejs/ mcarberry@bog:~/public_web/sitename/nodejs$ cp -r usr/local/* . mcarberry@bog:~/public_web/sitename/nodejs$ rm -r usr mcarberry@bog:~/public_web/sitename/nodejs$ cd .. mcarberry@bog:~/public_web/sitename$ rm -r node-v0.10.26/
Test Install
Change the port in this script (gleaned from here) to the one requested in the firewall rules and place it in ~/public_web/sitename/.
Configure your domain, modelling this example. This will foward requests to your domain to the port that you requested on bog. Give it a test run
mcarberry@bog:~/public_web/sitename$ ./nodejs/bin/node hello_world.js
If it works, when you visit your domain name you should see the Hello Node.js message.
Write a Script to Start the Server
- Here's a script I use to start my Node.js server running Ghost. You'll need to use k5start (as I do) in order to make sure your server is able to maintain access to AFS. You should be able to modify this script to your needs with not too much effort.
1 #!/bin/bash 2 HOME=/afs/hcoop.net/user/m/mc/mcarberry 3 GHOSTROOT=$HOME/public_web/ghost/ghost-app 4 NODEROOT=$HOME/public_web/ghost/nodejs 5 6 NODE=$NODEROOT/bin/node 7 8 PIDFILE=$GHOSTROOT/ghost.pid 9 10 K5START="k5start -qtUf /etc/keytabs/user.daemon/mcarberry" 11 12 cd $GHOSTROOT 13 14 NODE_CONFIG_DIR=$GHOSTROOT 15 16 if (test -f $PIDFILE); then 17 echo "PID File exists..." 18 PID=`cat $PIDFILE 2> /dev/null` 19 echo "Is previous server still running" 20 kill -0 $PID 2> /dev/null 21 if (test $? -ne 0); then 22 echo "Nope, starting server" 23 $K5START -b -c $PIDFILE -- $NODE $GHOSTROOT/index.js 24 else 25 echo "Yes, no need to start server" 26 exit 0 27 fi 28 else 29 echo "Starting server" 30 $K5START -b -c $PIDFILE -- $NODE $GHOSTROOT/index.js 31 fi
Add a Reboot Rule to Crontab
- Request crontab access throught the portal, and set a rule such that your script will be run in the event of bog being rebooted.