Nodejs: Difference between revisions

From Objectif Client Inc
Jump to navigation Jump to search
No edit summary
Line 33: Line 33:


== Server Installation ==
== Server Installation ==
mp2
=== pm2 Installation ===
* Install pm2 application
<pre>sudo npm install pm2 -g </pre>
 
* Copy init Script
<pre>pm2 startup ubuntu</pre>
 
* Adjust init Script (if necessary)
<pre> vi /etc/init.d/pm2-init.sh</pre>
 
 
=== pm2 Main commandes ===
 
* Start application: from inside the application folder
<pre>pm2 start bin/www
or pm2 start app.js</pre>
 
* List all runnng application
<pre>pm2 save</pre>
 
* Save current runnng application
<pre>pm2 list</pre>
 
pm2 describe 0
* Stop application
<pre>pm2 stop "id" </pre>
 
* Remove application
<pre>pm2 delete "id" </pre>
 
* Start web interface port 9615 (localhost:9615)
<pre>pm2 web</pre>
 
* Stop pm2 (kill all
<pre>pm2 kill</pre>

Revision as of 13:46, 23 March 2015

Client Installation

Install Node

  • Web site link [1]
  • Download Tar "node-v0.10.35.tar.gz" (version number may be different
  • untar tar -zxvf node-v0.10.35.tar.gz
  • cd node-v0.10.35
  • Run configure : ./configure
  • Run make : make
  • Run make with install : sudo make install

Install Express

  • sudo npm install -g express-generator

First App

  • Create your app directory mkdir myapp
  • Go into directory : cd myapp
  • Run express : express
  • Run npm  : npm install
  • test App : npm start
  • try http://localhost:3000

Tricks

Update Version (package.json)

npm-check-updates -u

Update Dependencies

npm install

Stop Restart with nodemon

nodemon
nodemon --debug

Server Installation

pm2 Installation

  • Install pm2 application
sudo npm install pm2 -g 
  • Copy init Script
pm2 startup ubuntu
  • Adjust init Script (if necessary)
 vi /etc/init.d/pm2-init.sh


pm2 Main commandes

  • Start application: from inside the application folder
pm2 start bin/www 
or pm2 start app.js
  • List all runnng application
pm2 save
  • Save current runnng application
pm2 list

pm2 describe 0

  • Stop application
pm2 stop "id" 
  • Remove application
pm2 delete "id" 
  • Start web interface port 9615 (localhost:9615)
pm2 web
  • Stop pm2 (kill all
pm2 kill