untitled.md 9.47 KB
Newer Older
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# Albiziapp Server Processes and DB

## App Processes 

Albiziapp VM hosts two distinct applications :

#### Albiziapp 

URL : https://albiziapp.reveries-project.fr

ssl : certbot

The Albiziapp application process is a node application managed by **pm2.** From a shell :

```bash
$ pm2 list
```

gives access to the list of process managed by pm2. Here, only one :

![](../.gitbook/assets/image%20%2810%29.png)

pm2 is very convenient to manage an app in production. Among others, it will restart the node app in case of crash, it keeps  `stdout` and `stderr` \(access through pm2 logs\):

```bash
$ pm2 logs osm-app --lines 100
/home/reveries/.pm2/logs/osm-app-error.log last 30 lines:
0|osm-app  | designed for a production environment, as it will leak
0|osm-app  | memory, and will not scale past a single process.
0|osm-app  | (node:17142) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
0|osm-app  | (node:17142) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
0|osm-app  | (node:17142) DeprecationWarning: collection.findAndModify is deprecated. Use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead.
0|osm-app  | { Error: connect ECONNREFUSED 127.0.0.1:8081
0|osm-app  |     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1106:14)
0|osm-app  |   errno: 'ECONNREFUSED',
0|osm-app  |   code: 'ECONNREFUSED',
0|osm-app  |   syscall: 'connect',
0|osm-app  |   address: '127.0.0.1',
0|osm-app  |   port: 8081 }
0|osm-app  | `encrypted` option is deprecated in favor of `useTLS`
0|osm-app  | Warning: connect.session() MemoryStore is not
0|osm-app  | designed for a production environment, as it will leak
0|osm-app  | memory, and will not scale past a single process.
0|osm-app  | (node:5041) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
0|osm-app  | { Error: connect ECONNREFUSED 127.0.0.1:8081
0|osm-app  |     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1106:14)
0|osm-app  |   errno: 'ECONNREFUSED',
0|osm-app  |   code: 'ECONNREFUSED',
0|osm-app  |   syscall: 'connect',
0|osm-app  |   address: '127.0.0.1',
0|osm-app  |   port: 8081 }
0|osm-app  | `encrypted` option is deprecated in favor of `useTLS`
0|osm-app  | Warning: connect.session() MemoryStore is not
0|osm-app  | designed for a production environment, as it will leak
0|osm-app  | memory, and will not scale past a single process.
0|osm-app  | (node:5077) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
0|osm-app  | (node:5077) DeprecationWarning: collection.findAndModify is deprecated. Use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead.

/home/reveries/.pm2/logs/osm-app-out.log last 30 lines:
0|osm-app  | 5d16635b4404bf15804f41de
0|osm-app  | 5d165faf4404bf15804f41ca
0|osm-app  | 5d165faf4404bf15804f41ca
0|osm-app  | 5d16128b7bfe04085df48fab
0|osm-app  | 5d1611c97bfe04085df48f99
0|osm-app  | 5d165e0e4404bf15804f41bd
0|osm-app  | 5d1612197bfe04085df48f9f
0|osm-app  | 5d16128b7bfe04085df48fab
0|osm-app  | 5d165faf4404bf15804f41ca
0|osm-app  | 5d165f2a4404bf15804f41c3
0|osm-app  | 5d165f2a4404bf15804f41c3
0|osm-app  | 5d165d7e4404bf15804f41b3
0|osm-app  | 5d165faf4404bf15804f41ca
0|osm-app  | 5d165d9a4404bf15804f41b8
0|osm-app  | 5d16615f4404bf15804f41d0
0|osm-app  | 5d16110a7bfe04085df48f8e
0|osm-app  | 5d1664714404bf15804f41e5
0|osm-app  | 5d1664ce4404bf15804f41eb
0|osm-app  | 5d1665a34404bf15804f41f1
0|osm-app  | 5d160ff97bfe04085df48f83
0|osm-app  | 5d16105e7bfe04085df48f89
0|osm-app  | 5d1612197bfe04085df48f9f
0|osm-app  | 5d1611c97bfe04085df48f99
0|osm-app  | 5d166c894404bf15804f4216
0|osm-app  | 5d166dca4404bf15804f421c
0|osm-app  | 5d166dca4404bf15804f421c
0|osm-app  | 5d16105e7bfe04085df48f89
0|osm-app  | 5d160ff97bfe04085df48f83
0|osm-app  | 5d1611c97bfe04085df48f99
0|osm-app  | 5d16110a7bfe04085df48f8e

```

 It also provides lot of usefull info about the process state \(pm2 show\)

```bash
reveries@albiziapp:~$ pm2 show 0
 Describing process with id 0 - name osm-app 
┌───────────────────┬────────────────────────────────────────────┐
│ status            │ online                                     │
│ name              │ osm-app                                    │
│ version           │ 1.0.0                                      │
│ restarts          │ 47                                         │
uptime            │ 51D                                        │
│ script path       │ /home/reveries/reveries-osm-data/index.js  │
│ script args       │ N/A                                        │
│ error log path    │ /home/reveries/.pm2/logs/osm-app-error.log │
│ out log path      │ /home/reveries/.pm2/logs/osm-app-out.log   │
│ pid path          │ /home/reveries/.pm2/pids/osm-app-0.pid     │
│ interpreter       │ node                                       │
│ interpreter args  │ N/A                                        │
│ script id         │ 0                                          │
exec cwd          │ /home/reveries/reveries-osm-data           │
exec mode         │ fork_mode                                  │
│ node.js version   │ 10.16.0                                    │
│ node env          │ production                                 │
│ watch & reload    │ ✔                                          │
│ unstable restarts │ 1                                          │
│ created at        │ 2019-10-01T12:28:09.759Z                   │
└───────────────────┴────────────────────────────────────────────┘
 Revision control metadata 
┌──────────────────┬───────────────────────────────────────────────────────────┐
│ revision control │ git                                                       │
│ remote url       │ https://github.com/REVERIES-project/reveries-osm-data.git │
│ repository root  │ /home/reveries/reveries-osm-data                          │
│ last update      │ 2019-09-27T09:34:16.930Z                                  │
│ revision         │ 8fa57dfecde55be9b3f6ca3d46f8648f1960fb63                  │
│ comment          │ key                                                       │
│ branch           │ master                                                    │
└──────────────────┴───────────────────────────────────────────────────────────┘
 Actions available 
┌────────────────────────┐
│ km:heapdump            │
│ km:cpu:profiling:start │
│ km:cpu:profiling:stop  │
│ km:heap:sampling:start │
│ km:heap:sampling:stop  │
└────────────────────────┘
 Trigger via: pm2 trigger osm-app <action_name>

 Code metrics value 
┌────────────────────────┬──────────────────────┐
│ Heap Size              │ 43.55 MiB            │
│ Heap Usage             │ 85.45 %              │
│ Used Heap Size         │ 37.21 MiB            │
│ Active requests        │ 0                    │
│ Active handles         │ 10                   │
│ Event Loop Latency     │ 0.82 ms              │
│ Event Loop Latency p95 │ 2.72 ms              │
│ HTTP Mean Latency      │ 2 ms                 │
│ HTTP P95 Latency       │ 85.64999999999986 ms │
│ HTTP                   │ 0 req/min            │
└────────────────────────┴──────────────────────┘
 Divergent env variables from local env 
┌────────────────┬───────────────────────────────────────┐
│ SSH_CONNECTION │ 172.30.1.216 46178 193.52.29.161 2202 │
│ XDG_SESSION_ID │ 128                                   │
│ PWD            │ /home/reveries/reveries-osm-data      │
│ SSH_CLIENT     │ 172.30.1.216 46178 2202               │
└────────────────┴───────────────────────────────────────┘


```

{% hint style="info" %}
 Super-powers are granted randomly so please submit an issue if you're not happy with yours.
{% endhint %}

Once you're strong enough, save the world:

{% code title="hello.sh" %}
```bash
# Ain't no code for that yet, sorry
echo 'You got to trust me on this, I saved the world'
```
{% endcode %}


178