-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathaws_setup.txt
130 lines (90 loc) · 3.72 KB
/
aws_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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
Amazon AWS EC2 Instances
// install python 2.7
sudo apt-get install python2.7
python -V
// install python 3.5
sudo apt-get install python3.5
python3 -V
// install node 8.x.x
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
pm2 - help run app in background
npm install pm2@latest -g
pm2 start app.js
pm2 Cheat sheet commands
----------------------------------
# Fork mode
pm2 start app.js --name my-api # Name process
# Cluster mode
pm2 start app.js -i 0 # Will start maximum processes with LB depending on available CPUs
pm2 start app.js -i max # Same as above, but deprecated.
# Listing
pm2 list # Display all processes status
pm2 jlist # Print process list in raw JSON
pm2 prettylist # Print process list in beautified JSON
pm2 describe 0 # Display all informations about a specific process
pm2 monit # Monitor all processes
# Logs
pm2 logs [--raw] # Display all processes logs in streaming
pm2 flush # Empty all log file
pm2 reloadLogs # Reload all logs
# Actions
pm2 stop all # Stop all processes
pm2 restart all # Restart all processes
pm2 reload all # Will 0s downtime reload (for NETWORKED apps)
pm2 stop 0 # Stop specific process id
pm2 restart 0 # Restart specific process id
pm2 delete 0 # Will remove process from pm2 list
pm2 delete all # Will remove all processes from pm2 list
# Misc
pm2 reset <process> # Reset meta data (restarted time...)
pm2 updatePM2 # Update in memory pm2
pm2 ping # Ensure pm2 daemon has been launched
pm2 sendSignal SIGUSR2 my-app # Send system signal to script
pm2 start app.js --no-daemon
pm2 start app.js --no-vizion
pm2 start app.js --no-autorestart
pm2 start app.js # Start app.js
pm2 start app.js -- -a 23 # Pass arguments '-a 23' argument to app.js script
pm2 start app.js --name serverone # Start a process and name it as serverone
# you can now stop the process by doing
# pm2 stop serverone
pm2 start app.js --node-args="--debug=7001" # --node-args to pass options to node V8
pm2 start app.js -i 0 # Start maximum processes depending on available CPUs (cluster mode)
pm2 start app.js --log-date-format "YYYY-MM-DD HH:mm Z" # Log will be prefixed with custom time format
pm2 start app.json # Start processes with options declared in app.json
# Go to chapter Multi process JSON declaration for more
pm2 start app.js -e err.log -o out.log # Start and specify error and out log
shell cmd for creating user in mongoDB
mongo
use entirenews
db.createUser({user:"EntireNewsApp",pwd:"Js3dgK5sdg7BHJIsdGH89JdKsd9fB0",roles:[{role:"readWrite",db:"entirenews"}]})
then
sudo nano /etc/mongod.conf
#enable security like this
. . .
security:
authorization: "enabled"
. . .
then restart mongod server
For windows: move this file to "C:\Program Files\Git\usr\bin"
Then open CMD or Terminal with Admin access
>>cd C:\Program Files\Git\usr\bin
>>chmod 400 EntireNews.pem
>>ssh -i EntireNews.pem ubuntu@ec2-52-10-35-26.us-west-2.compute.amazonaws.com -p 22
>>mkdir entirenews
>>cd entirenews
>>mkdir python
>>mkdir nodejs
>>ls
>>cd nodejs
// run chmod only once, u don't need to do it every time
// ignore mkdir commands now, as i have already created all those dirs
MongoD - Status
sudo systemctl status mongod
sudo systemctl start mongod // to run
sudo systemctl stop mongod // to stop
sudo systemctl restart mongod // to restart
press 'q' to quit in STATUS mode
to login to mongo
mongo --port 27017 -u EntireNewsApp -p XXX --authenticationDatabase entirenews