-
Notifications
You must be signed in to change notification settings - Fork 0
/
socketio_node_setup.txt
76 lines (49 loc) · 1.5 KB
/
socketio_node_setup.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
sudo apt-get install curl git
sudo apt-get install build-essential
sudo apt-get install curl openssl libssl-dev
git clone https://github.com/joyent/node.git
cd node
git checkout v0.10.36
./configure
make
sudo make install
node -v
rm -rf /home/vagrant/node
#run iosocket server in debug mode
DEBUG=socket.io:socket node app.js
#run iosocket server
node app.js
#production run using pm2
#ensures restarting node application as a service every time server is restarted
#automatically restarts the node application if it crashes
# https://github.com/Unitech/pm2
sudo npm install pm2 -g
pm2 start app.js
# pm2 startup ubuntu
sudo env PATH=$PATH:/usr/local/bin pm2 startup -u vagrant
#Run multiple processes of the application. PM2 will run one process per CPU core.
#It will also attempt to load balance requests between the running processes.
pm2 start app.js --name "socketio" -i max
# Reload and restart the application (or use gracefulReload >useful for closing all existing connections before restarting.)
pm2 reload app.js
# Stop the application
pm2 stop app.js
# Remove app.js from PM2
pm2 delete app.js
#dumps node processes and saves them as JSON and is used to configure running processes on startup.
pm2 save
# List processes monitored
pm2 list
# See "tail" style log output of all logs output from watched processes
pm2 logs
# Clear all logs
pm2 flush
# List process 0
pm2 desc 0
# Monitor processes and system usage
pm2 monit
pm2 dump
pm2 kill
pm2 resurect
#web interface http://localhost:9615
pm2 web