20190916_jeffrey - silenceuncrio/diary GitHub Wiki
上週四臨時請假
先補周報
M300[release/v2.01]
- display 'LTE > GPS' when PROSRC_GNSS and PROSRC_GNSS_LAB all turn on
M330[develop]
- if 'Work As' 'Static IPv4', force 'dns4_from' to 1(User Defined)
- read config from web.ini at boot time
M360P[release/v1.04]
- add 'lte reboot' field at 'LTE > Dual APN' page
- add 'Management > Web' for user to change the HTTP/HTTPS port
- now our web module supports 4 modes: Off, HTTP, HTTPS and Both
- no more workaround needed since we do not use iweb anymore
commit 1a6534abac0e479cbc37555a72b40272cf4db219
Refs: [release/v1.04], {origin/release/v1.04}
Author: jeffrey <[email protected]>
Date: Mon Sep 16 11:34:37 2019 +0800
add 'Firewall > Basic Rules'
proscend/prosrc/icos/include/module_firewall.h | 2 +
proscend/prosrc/webcgi/firewall.c | 34 +++++++-
proscend/prosrc/www/app/feature/basicRules.html | 105 ++++++++++++++++++++++++
proscend/prosrc/www/app/feature/basicRules.js | 48 +++++++++++
proscend/prosrc/www/app/locale-en.json | 19 +++++
proscend/prosrc/www/app/locale-fr.json | 19 +++++
proscend/prosrc/www/app/locale-zh-tw.json | 19 +++++
proscend/prosrc/www/src/index.html.src | 1 +
proscend/prosrc/www/src/menu.html.src | 3 +
9 files changed, 249 insertions(+), 1 deletion(-)
commit d8ca5bebafd1d2b37ae8b785b4d8ffadd8653420
Refs: [release/v1.04], {origin/release/v1.04}
Author: jeffrey <[email protected]>
Date: Mon Sep 16 11:46:58 2019 +0800
add online user manual - 'Firewall > Basic Rules'
proscend/prosrc/www/src/manual.html.src | 3 ++
.../www/src/manual/firewall_basic_rules.h.html | 33 ++++++++++++++++++++++
proscend/prosrc/www/src/manual/sidebar.h.html | 3 ++
3 files changed, 39 insertions(+)
commit df0124d878729871400537142c47bf61421e709d
Refs: [release/v1.04], {origin/release/v1.04}
Author: jeffrey <[email protected]>
Date: Mon Sep 16 11:53:10 2019 +0800
update online user manual - 'Management > Web'
proscend/prosrc/www/src/manual/management_web.h.html | 9 +++++++++
1 file changed, 9 insertions(+)
commit 7d7f82a93fcf8b8fedbb0b43a38659e891ecbf68
Refs: [release/v1.04], {origin/release/v1.04}
Author: jeffrey <[email protected]>
Date: Mon Sep 16 11:58:12 2019 +0800
add online user manual - 'Management > Telnet'
proscend/prosrc/www/src/manual.html.src | 1 +
.../prosrc/www/src/manual/management_telnet.h.html | 30 ++++++++++++++++++++++
proscend/prosrc/www/src/manual/sidebar.h.html | 3 +++
3 files changed, 34 insertions(+)
繼續進行 M330 - GPS Track Server 端的佈建
先對之前的 survey 做個摘要
-
The official Node.js docker image
- 官方 維護的 node.js 的 docker image
-
Dockerize a Node.js service with MongoDB using Docker Compose
- 只有 study 但還沒實際跑跑看
-
How To Setup Node Express And MongoDB In Docker
- 忘了有沒有實際跑跑看
-
How To Build a Node.js Application with Docker
- 太多了 懶得看
-
Build a CRUD API with MongoDB, Express, and Docker
- 圖都壞了 放棄
-
How to create a full stack React/Express/MongoDB app using Docker
- study 最對味
- docker compose 有問題
耐著性子在把比較有價值的再 review 一下
-
Dockerize a Node.js service with MongoDB using Docker Compose
- 只有 study 但還沒實際跑跑看
-
How To Setup Node Express And MongoDB In Docker
- 忘了有沒有實際跑跑看
-
How to create a full stack React/Express/MongoDB app using Docker
- study 最對味
- docker compose 有問題
Dockerize a Node.js service with MongoDB using Docker Compose
這有個 source code 可以直接 clone 來試
➜ ~ git clone https://github.com/rahil471/nodejs-mongo-docker-sample.git
Cloning into 'nodejs-mongo-docker-sample'...
remote: Enumerating objects: 22, done.
remote: Total 22 (delta 0), reused 0 (delta 0), pack-reused 22
Unpacking objects: 100% (22/22), done.
Checking connectivity... done.
➜ ~ cd nodejs-mongo-docker-sample
➜ nodejs-mongo-docker-sample git:(master) ls
app.js docker-compose.yml Dockerfile LICENSE models package.json package-lock.json process.json README.md
直接照著 github 上的指令做事 - docker-compose up --build
➜ nodejs-mongo-docker-sample git:(master) docker-compose up --build
Creating network "nodejs-mongo-docker-sample_default" with the default driver
Building myapp
Step 1/9 : FROM node:boron
boron: Pulling from library/node
c5e155d5a1d1: Pull complete
221d80d00ae9: Pull complete
4250b3117dca: Pull complete
3b7ca19181b2: Pull complete
425d7b2a5bcc: Pull complete
69df12c70287: Pull complete
ea2f5386a42d: Pull complete
d421d2b3c5eb: Pull complete
Digest: sha256:e133e66ec3bfc98da0440e552f452e5cdf6413319d27a2db3b01ac4b319759b3
Status: Downloaded newer image for node:boron
---> ab290b853066
Step 2/9 : WORKDIR /usr/src/app
Removing intermediate container 0c1358c1e5b2
---> 5a6b9ba481bb
Step 3/9 : COPY package.json /usr/src/app
---> ceb9a8b63f12
Step 4/9 : COPY package-lock.json /usr/src/app
---> 91bfb4cbab82
Step 5/9 : RUN npm install
---> Running in da70a1cf3f1f
> [email protected] postinstall /usr/src/app/node_modules/core-js
> node scripts/postinstall || echo "ignore"
[email protected] /usr/src/app
...
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
Removing intermediate container da70a1cf3f1f
---> 04bc71474586
Step 6/9 : RUN npm install pm2 -g
---> Running in 1c4ead5d3c36
/usr/local/bin/pm2 -> /usr/local/lib/node_modules/pm2/bin/pm2
/usr/local/bin/pm2-dev -> /usr/local/lib/node_modules/pm2/bin/pm2-dev
/usr/local/bin/pm2-runtime -> /usr/local/lib/node_modules/pm2/bin/pm2-runtime
/usr/local/bin/pm2-docker -> /usr/local/lib/node_modules/pm2/bin/pm2-docker
/usr/local/lib
...
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/pm2/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
Removing intermediate container 1c4ead5d3c36
---> b074faa5290c
Step 7/9 : COPY . /usr/src/app
---> 659dccbacc44
Step 8/9 : EXPOSE 3000
---> Running in b1ff8625d85a
Removing intermediate container b1ff8625d85a
---> b45725dd55d2
Step 9/9 : CMD ["pm2-docker", "start", "process.json"]
---> Running in 87d97b2b8f2b
Removing intermediate container 87d97b2b8f2b
---> dbc56ecb79ff
Successfully built dbc56ecb79ff
Successfully tagged nodejs-mongo-docker-sample_myapp:latest
Creating nodejs-mongo-docker-sample_database_1 ... done
Creating nodejs-mongo-docker-sample_myapp_1 ... done
Attaching to nodejs-mongo-docker-sample_database_1, nodejs-mongo-docker-sample_myapp_1
database_1 | 2019-09-16T05:24:44.420+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
database_1 | 2019-09-16T05:24:44.494+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=e7af356e2d0d
database_1 | 2019-09-16T05:24:44.494+0000 I CONTROL [initandlisten] db version v4.2.0
database_1 | 2019-09-16T05:24:44.494+0000 I CONTROL [initandlisten] git version: a4b751dcf51dd249c5865812b390cfd1c0129c30
database_1 | 2019-09-16T05:24:44.494+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1 11 Sep 2018
database_1 | 2019-09-16T05:24:44.494+0000 I CONTROL [initandlisten] allocator: tcmalloc
database_1 | 2019-09-16T05:24:44.494+0000 I CONTROL [initandlisten] modules: none
database_1 | 2019-09-16T05:24:44.494+0000 I CONTROL [initandlisten] build environment:
database_1 | 2019-09-16T05:24:44.494+0000 I CONTROL [initandlisten] distmod: ubuntu1804
database_1 | 2019-09-16T05:24:44.494+0000 I CONTROL [initandlisten] distarch: x86_64
database_1 | 2019-09-16T05:24:44.494+0000 I CONTROL [initandlisten] target_arch: x86_64
database_1 | 2019-09-16T05:24:44.494+0000 I CONTROL [initandlisten] options: { net: { bindIp: "*" } }
database_1 | 2019-09-16T05:24:44.495+0000 I STORAGE [initandlisten]
database_1 | 2019-09-16T05:24:44.495+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
database_1 | 2019-09-16T05:24:44.495+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
database_1 | 2019-09-16T05:24:44.495+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=473M,cache_overflow=(file_max=0M),session_max=33000,eviction=(threads_min=4,threads_max=4),config_
base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress],
myapp_1 | 2019-09-16T05:24:45: PM2 log: Launching in no daemon mode
myapp_1 | 2019-09-16T05:24:45: PM2 log: App [myapp:0] starting in -cluster mode-
database_1 | 2019-09-16T05:24:45.393+0000 I STORAGE [initandlisten] WiredTiger message [1568611485:393331][1:0x7f3e35e82b00], txn-recover: Set global recovery timestamp: (0,0) [241/900]
myapp_1 | 2019-09-16T05:24:45: PM2 log: App [myapp:0] online
database_1 | 2019-09-16T05:24:45.442+0000 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
database_1 | 2019-09-16T05:24:45.510+0000 I STORAGE [initandlisten] Timestamp monitor starting
database_1 | 2019-09-16T05:24:45.622+0000 I CONTROL [initandlisten]
database_1 | 2019-09-16T05:24:45.622+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
database_1 | 2019-09-16T05:24:45.622+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
database_1 | 2019-09-16T05:24:45.622+0000 I CONTROL [initandlisten]
myapp_1 | Error: Cannot find module 'express'
myapp_1 | at Function.Module._resolveFilename (module.js:476:15)
myapp_1 | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:51:29)
myapp_1 | at require (internal/module.js:20:19)
myapp_1 | at Object.<anonymous> (/usr/src/app/app.js:1:77)
myapp_1 | at Module._compile (module.js:577:32)
myapp_1 | at Object.Module._extensions..js (module.js:586:10)
myapp_1 | at Module.load (module.js:494:32)
myapp_1 | at tryModuleLoad (module.js:453:12)
myapp_1 | at Function.Module._load (module.js:445:3)
myapp_1 | at /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:295:23
myapp_1 | 2019-09-16T05:24:45: PM2 log: App name:myapp id:0 disconnected
myapp_1 | 2019-09-16T05:24:45: PM2 log: App [myapp:0] exited with code [0] via signal [SIGINT]
myapp_1 | 2019-09-16T05:24:45: PM2 log: App [myapp:0] starting in -cluster mode-
myapp_1 | 2019-09-16T05:24:45: PM2 log: App [myapp:0] online
database_1 | 2019-09-16T05:24:45.823+0000 I STORAGE [initandlisten] createCollection: admin.system.version with provided UUID: 243be69c-db7d-40bc-a57f-d9aa26fe9cc2 and options: { uuid: UUID("243be69c-db7d-40b
c-a57f-d9aa26fe9cc2") }
myapp_1 | Error: Cannot find module 'express'
myapp_1 | at Function.Module._resolveFilename (module.js:476:15)
myapp_1 | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:51:29)
myapp_1 | at require (internal/module.js:20:19)
myapp_1 | at Object.<anonymous> (/usr/src/app/app.js:1:77)
myapp_1 | at Module._compile (module.js:577:32)
myapp_1 | at Object.Module._extensions..js (module.js:586:10)
myapp_1 | at Module.load (module.js:494:32)
myapp_1 | at tryModuleLoad (module.js:453:12)
myapp_1 | at Function.Module._load (module.js:445:3)
myapp_1 | at /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:295:23
myapp_1 | 2019-09-16T05:24:45: PM2 log: App name:myapp id:0 disconnected
myapp_1 | 2019-09-16T05:24:45: PM2 log: App [myapp:0] exited with code [0] via signal [SIGINT]
myapp_1 | 2019-09-16T05:24:45: PM2 log: App [myapp:0] starting in -cluster mode-
database_1 | 2019-09-16T05:24:45.924+0000 I INDEX [initandlisten] index build: done building index _id_ on ns admin.system.version
myapp_1 | 2019-09-16T05:24:45: PM2 log: App [myapp:0] online
database_1 | 2019-09-16T05:24:45.938+0000 I SHARDING [initandlisten] Marking collection admin.system.version as collection version: <unsharded>
database_1 | 2019-09-16T05:24:45.938+0000 I COMMAND [initandlisten] setting featureCompatibilityVersion to 4.2
database_1 | 2019-09-16T05:24:45.941+0000 I SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
database_1 | 2019-09-16T05:24:45.987+0000 I STORAGE [initandlisten] Flow Control is enabled on this deployment.
database_1 | 2019-09-16T05:24:45.999+0000 I SHARDING [initandlisten] Marking collection admin.system.roles as collection version: <unsharded>
database_1 | 2019-09-16T05:24:46.009+0000 I STORAGE [initandlisten] createCollection: local.startup_log with generated UUID: a65aa110-9774-4681-bee9-56eb2d3812ac and options: { capped: true, size: 10485760 }
database_1 | 2019-09-16T05:24:46.057+0000 I INDEX [initandlisten] index build: done building index _id_ on ns local.startup_log
database_1 | 2019-09-16T05:24:46.057+0000 I SHARDING [initandlisten] Marking collection local.startup_log as collection version: <unsharded>
database_1 | 2019-09-16T05:24:46.058+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
database_1 | 2019-09-16T05:24:46.101+0000 I SHARDING [LogicalSessionCacheReap] Marking collection config.system.sessions as collection version: <unsharded>
database_1 | 2019-09-16T05:24:46.101+0000 I NETWORK [initandlisten] Listening on /tmp/mongodb-27017.sock [190/900]
database_1 | 2019-09-16T05:24:46.101+0000 I NETWORK [initandlisten] Listening on 0.0.0.0
database_1 | 2019-09-16T05:24:46.102+0000 I NETWORK [initandlisten] waiting for connections on port 27017
myapp_1 | Error: Cannot find module 'express'
myapp_1 | at Function.Module._resolveFilename (module.js:476:15)
myapp_1 | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:51:29)
myapp_1 | at require (internal/module.js:20:19)
myapp_1 | at Object.<anonymous> (/usr/src/app/app.js:1:77)
myapp_1 | at Module._compile (module.js:577:32)
myapp_1 | at Object.Module._extensions..js (module.js:586:10)
myapp_1 | at Module.load (module.js:494:32)
myapp_1 | at tryModuleLoad (module.js:453:12)
myapp_1 | at Function.Module._load (module.js:445:3)
myapp_1 | at /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:295:23
myapp_1 | 2019-09-16T05:24:46: PM2 log: App name:myapp id:0 disconnected
myapp_1 | 2019-09-16T05:24:46: PM2 log: App [myapp:0] exited with code [0] via signal [SIGINT]
myapp_1 | 2019-09-16T05:24:46: PM2 log: App [myapp:0] starting in -cluster mode-
myapp_1 | 2019-09-16T05:24:46: PM2 log: App [myapp:0] online
database_1 | 2019-09-16T05:24:46.235+0000 I COMMAND [LogicalSessionCacheReap] command config.system.sessions command: listIndexes { listIndexes: "system.sessions", cursor: {}, $db: "config" } numYields:0 ok:0
errMsg:"ns does not exist: config.system.sessions" errName:NamespaceNotFound errCode:26 reslen:134 locks:{ ReplicationStateTransition: { acquireCount: { w: 2 } }, Global: { acquireCount: { r: 2 } }, Database: {
acquireCount: { r: 2 } }, Collection: { acquireCount: { r: 1 } } } protocol:op_msg 134ms
database_1 | 2019-09-16T05:24:46.235+0000 I COMMAND [LogicalSessionCacheRefresh] command config.system.sessions command: listIndexes { listIndexes: "system.sessions", cursor: {}, $db: "config" } numYields:0 o
k:0 errMsg:"ns does not exist: config.system.sessions" errName:NamespaceNotFound errCode:26 reslen:134 locks:{ ReplicationStateTransition: { acquireCount: { w: 2 } }, Global: { acquireCount: { r: 2 } }, Database
: { acquireCount: { r: 2 } }, Collection: { acquireCount: { r: 1 } } } protocol:op_msg 134ms
database_1 | 2019-09-16T05:24:46.235+0000 I STORAGE [LogicalSessionCacheRefresh] createCollection: config.system.sessions with provided UUID: e3c95f68-4234-4dec-9923-d759b5605ee9 and options: { uuid: UUID("e3
c95f68-4234-4dec-9923-d759b5605ee9") }
database_1 | 2019-09-16T05:24:46.236+0000 I CONTROL [LogicalSessionCacheReap] Sessions collection is not set up; waiting until next sessions reap interval: config.system.sessions does not exist
database_1 | 2019-09-16T05:24:46.287+0000 I INDEX [LogicalSessionCacheRefresh] index build: done building index _id_ on ns config.system.sessions
database_1 | 2019-09-16T05:24:46.347+0000 I INDEX [LogicalSessionCacheRefresh] index build: starting on config.system.sessions properties: { v: 2, key: { lastUse: 1 }, name: "lsidTTLIndex", ns: "config.syst
em.sessions", expireAfterSeconds: 1800 } using method: Hybrid
database_1 | 2019-09-16T05:24:46.347+0000 I INDEX [LogicalSessionCacheRefresh] build may temporarily use up to 500 megabytes of RAM
database_1 | 2019-09-16T05:24:46.347+0000 I INDEX [LogicalSessionCacheRefresh] index build: collection scan done. scanned 0 total records in 0 seconds
database_1 | 2019-09-16T05:24:46.348+0000 I INDEX [LogicalSessionCacheRefresh] index build: inserted 0 keys from external sorter into index in 0 seconds
database_1 | 2019-09-16T05:24:46.359+0000 I INDEX [LogicalSessionCacheRefresh] index build: done building index lsidTTLIndex on ns config.system.sessions
myapp_1 | Error: Cannot find module 'express'
myapp_1 | at Function.Module._resolveFilename (module.js:476:15)
myapp_1 | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:51:29)
myapp_1 | at require (internal/module.js:20:19)
myapp_1 | at Object.<anonymous> (/usr/src/app/app.js:1:77)
myapp_1 | at Module._compile (module.js:577:32)
myapp_1 | at Object.Module._extensions..js (module.js:586:10)
myapp_1 | at Module.load (module.js:494:32)
myapp_1 | at tryModuleLoad (module.js:453:12)
myapp_1 | at Function.Module._load (module.js:445:3)
myapp_1 | at /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:295:23
myapp_1 | 2019-09-16T05:24:46: PM2 log: App name:myapp id:0 disconnected
myapp_1 | 2019-09-16T05:24:46: PM2 log: App [myapp:0] exited with code [0] via signal [SIGINT]
database_1 | 2019-09-16T05:24:46.368+0000 I COMMAND [LogicalSessionCacheRefresh] command config.system.sessions command: createIndexes { createIndexes: "system.sessions", indexes: [ { key: { lastUse: 1 }, nam
e: "lsidTTLIndex", expireAfterSeconds: 1800 } ], $db: "config" } numYields:0 reslen:114 locks:{ ParallelBatchWriterMode: { acquireCount: { r: 2 } }, ReplicationStateTransition: { acquireCount: { w: 3 } }, Global
: { acquireCount: { r: 1, w: 2 } }, Database: { acquireCount: { r: 1, w: 2, W: 1 } }, Collection: { acquireCount: { r: 4, w: 1, R: 1, W: 2 } }, Mutex: { acquireCount: { r: 3 } } } flowControl:{ acquireCount: 1 }
storage:{} protocol:op_msg 133ms
myapp_1 | 2019-09-16T05:24:46: PM2 log: App [myapp:0] starting in -cluster mode- [139/900]
myapp_1 | 2019-09-16T05:24:46: PM2 log: App [myapp:0] online
myapp_1 | Error: Cannot find module 'express'
myapp_1 | at Function.Module._resolveFilename (module.js:476:15)
myapp_1 | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:51:29)
myapp_1 | at require (internal/module.js:20:19)
myapp_1 | at Object.<anonymous> (/usr/src/app/app.js:1:77)
myapp_1 | at Module._compile (module.js:577:32)
myapp_1 | at Object.Module._extensions..js (module.js:586:10)
myapp_1 | at Module.load (module.js:494:32)
myapp_1 | at tryModuleLoad (module.js:453:12)
myapp_1 | at Function.Module._load (module.js:445:3)
myapp_1 | at /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:295:23
myapp_1 | 2019-09-16T05:24:46: PM2 log: App name:myapp id:0 disconnected
myapp_1 | 2019-09-16T05:24:46: PM2 log: App [myapp:0] exited with code [0] via signal [SIGINT]
myapp_1 | 2019-09-16T05:24:46: PM2 log: App [myapp:0] starting in -cluster mode-
myapp_1 | 2019-09-16T05:24:46: PM2 log: App [myapp:0] online
myapp_1 | Error: Cannot find module 'express'
myapp_1 | at Function.Module._resolveFilename (module.js:476:15)
myapp_1 | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:51:29)
myapp_1 | at require (internal/module.js:20:19)
myapp_1 | at Object.<anonymous> (/usr/src/app/app.js:1:77)
myapp_1 | at Module._compile (module.js:577:32)
myapp_1 | at Object.Module._extensions..js (module.js:586:10)
myapp_1 | at Module.load (module.js:494:32)
myapp_1 | at tryModuleLoad (module.js:453:12)
myapp_1 | at Function.Module._load (module.js:445:3)
myapp_1 | at /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:295:23
myapp_1 | 2019-09-16T05:24:46: PM2 log: App name:myapp id:0 disconnected
myapp_1 | 2019-09-16T05:24:46: PM2 log: App [myapp:0] exited with code [0] via signal [SIGINT]
myapp_1 | 2019-09-16T05:24:46: PM2 log: App [myapp:0] starting in -cluster mode-
myapp_1 | 2019-09-16T05:24:46: PM2 log: App [myapp:0] online
myapp_1 | Error: Cannot find module 'express'
myapp_1 | at Function.Module._resolveFilename (module.js:476:15)
myapp_1 | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:51:29)
myapp_1 | at require (internal/module.js:20:19)
myapp_1 | at Object.<anonymous> (/usr/src/app/app.js:1:77)
myapp_1 | at Module._compile (module.js:577:32)
myapp_1 | at Object.Module._extensions..js (module.js:586:10)
myapp_1 | at Module.load (module.js:494:32)
myapp_1 | at tryModuleLoad (module.js:453:12)
myapp_1 | at Function.Module._load (module.js:445:3)
myapp_1 | at /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:295:23
myapp_1 | 2019-09-16T05:24:47: PM2 log: App name:myapp id:0 disconnected
myapp_1 | 2019-09-16T05:24:47: PM2 log: App [myapp:0] exited with code [0] via signal [SIGINT]
myapp_1 | 2019-09-16T05:24:47: PM2 log: App [myapp:0] starting in -cluster mode-
myapp_1 | 2019-09-16T05:24:47: PM2 log: App [myapp:0] online
myapp_1 | Error: Cannot find module 'express'
myapp_1 | at Function.Module._resolveFilename (module.js:476:15)
myapp_1 | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:51:29)
myapp_1 | at require (internal/module.js:20:19)
myapp_1 | at Object.<anonymous> (/usr/src/app/app.js:1:77) [88/900]
myapp_1 | at Module._compile (module.js:577:32)
myapp_1 | at Object.Module._extensions..js (module.js:586:10)
myapp_1 | at Module.load (module.js:494:32)
myapp_1 | at tryModuleLoad (module.js:453:12)
myapp_1 | at Function.Module._load (module.js:445:3)
myapp_1 | at /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:295:23
myapp_1 | 2019-09-16T05:24:47: PM2 log: App name:myapp id:0 disconnected
myapp_1 | 2019-09-16T05:24:47: PM2 log: App [myapp:0] exited with code [0] via signal [SIGINT]
myapp_1 | 2019-09-16T05:24:47: PM2 log: App [myapp:0] starting in -cluster mode-
myapp_1 | 2019-09-16T05:24:47: PM2 log: App [myapp:0] online
myapp_1 | Error: Cannot find module 'express'
myapp_1 | at Function.Module._resolveFilename (module.js:476:15)
myapp_1 | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:51:29)
myapp_1 | at require (internal/module.js:20:19)
myapp_1 | at Object.<anonymous> (/usr/src/app/app.js:1:77)
myapp_1 | at Module._compile (module.js:577:32)
myapp_1 | at Object.Module._extensions..js (module.js:586:10)
myapp_1 | at Module.load (module.js:494:32)
myapp_1 | at tryModuleLoad (module.js:453:12)
myapp_1 | at Function.Module._load (module.js:445:3)
myapp_1 | at /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:295:23
myapp_1 | 2019-09-16T05:24:47: PM2 log: App name:myapp id:0 disconnected
myapp_1 | 2019-09-16T05:24:47: PM2 log: App [myapp:0] exited with code [0] via signal [SIGINT]
myapp_1 | 2019-09-16T05:24:47: PM2 log: App [myapp:0] starting in -cluster mode-
myapp_1 | 2019-09-16T05:24:47: PM2 log: App [myapp:0] online
myapp_1 | Error: Cannot find module 'express'
myapp_1 | at Function.Module._resolveFilename (module.js:476:15)
myapp_1 | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:51:29)
myapp_1 | at require (internal/module.js:20:19)
myapp_1 | at Object.<anonymous> (/usr/src/app/app.js:1:77)
myapp_1 | at Module._compile (module.js:577:32)
myapp_1 | at Object.Module._extensions..js (module.js:586:10)
myapp_1 | at Module.load (module.js:494:32)
myapp_1 | at tryModuleLoad (module.js:453:12)
myapp_1 | at Function.Module._load (module.js:445:3)
myapp_1 | at /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:295:23
myapp_1 | 2019-09-16T05:24:47: PM2 log: App name:myapp id:0 disconnected
myapp_1 | 2019-09-16T05:24:47: PM2 log: App [myapp:0] exited with code [0] via signal [SIGINT]
myapp_1 | 2019-09-16T05:24:47: PM2 log: App [myapp:0] starting in -cluster mode-
myapp_1 | 2019-09-16T05:24:47: PM2 log: App [myapp:0] online
myapp_1 | Error: Cannot find module 'express'
myapp_1 | at Function.Module._resolveFilename (module.js:476:15)
myapp_1 | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:51:29)
myapp_1 | at require (internal/module.js:20:19)
myapp_1 | at Object.<anonymous> (/usr/src/app/app.js:1:77)
myapp_1 | at Module._compile (module.js:577:32)
myapp_1 | at Object.Module._extensions..js (module.js:586:10)
myapp_1 | at Module.load (module.js:494:32)
myapp_1 | at tryModuleLoad (module.js:453:12)
myapp_1 | at Function.Module._load (module.js:445:3)
myapp_1 | at /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:295:23 [37/900]
myapp_1 | 2019-09-16T05:24:48: PM2 log: App name:myapp id:0 disconnected
myapp_1 | 2019-09-16T05:24:48: PM2 log: App [myapp:0] exited with code [0] via signal [SIGINT]
myapp_1 | 2019-09-16T05:24:48: PM2 log: App [myapp:0] starting in -cluster mode-
myapp_1 | 2019-09-16T05:24:48: PM2 log: App [myapp:0] online
myapp_1 | Error: Cannot find module 'express'
myapp_1 | at Function.Module._resolveFilename (module.js:476:15)
myapp_1 | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:51:29)
myapp_1 | at require (internal/module.js:20:19)
myapp_1 | at Object.<anonymous> (/usr/src/app/app.js:1:77)
myapp_1 | at Module._compile (module.js:577:32)
myapp_1 | at Object.Module._extensions..js (module.js:586:10)
myapp_1 | at Module.load (module.js:494:32)
myapp_1 | at tryModuleLoad (module.js:453:12)
myapp_1 | at Function.Module._load (module.js:445:3)
myapp_1 | at /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:295:23
myapp_1 | 2019-09-16T05:24:48: PM2 log: App name:myapp id:0 disconnected
myapp_1 | 2019-09-16T05:24:48: PM2 log: App [myapp:0] exited with code [0] via signal [SIGINT]
myapp_1 | 2019-09-16T05:24:48: PM2 log: App [myapp:0] starting in -cluster mode-
myapp_1 | 2019-09-16T05:24:48: PM2 log: App [myapp:0] online
myapp_1 | Error: Cannot find module 'express'
myapp_1 | at Function.Module._resolveFilename (module.js:476:15)
myapp_1 | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:51:29)
myapp_1 | at require (internal/module.js:20:19)
myapp_1 | at Object.<anonymous> (/usr/src/app/app.js:1:77)
myapp_1 | at Module._compile (module.js:577:32)
myapp_1 | at Object.Module._extensions..js (module.js:586:10)
myapp_1 | at Module.load (module.js:494:32)
myapp_1 | at tryModuleLoad (module.js:453:12)
myapp_1 | at Function.Module._load (module.js:445:3)
myapp_1 | at /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:295:23
myapp_1 | 2019-09-16T05:24:48: PM2 log: App name:myapp id:0 disconnected
myapp_1 | 2019-09-16T05:24:48: PM2 log: App [myapp:0] exited with code [0] via signal [SIGINT]
myapp_1 | 2019-09-16T05:24:48: PM2 log: App [myapp:0] starting in -cluster mode-
myapp_1 | 2019-09-16T05:24:48: PM2 log: App [myapp:0] online
myapp_1 | Error: Cannot find module 'express'
myapp_1 | at Function.Module._resolveFilename (module.js:476:15)
myapp_1 | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:51:29)
myapp_1 | at require (internal/module.js:20:19)
myapp_1 | at Object.<anonymous> (/usr/src/app/app.js:1:77)
myapp_1 | at Module._compile (module.js:577:32)
myapp_1 | at Object.Module._extensions..js (module.js:586:10)
myapp_1 | at Module.load (module.js:494:32)
myapp_1 | at tryModuleLoad (module.js:453:12)
myapp_1 | at Function.Module._load (module.js:445:3)
myapp_1 | at /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:295:23
myapp_1 | 2019-09-16T05:24:48: PM2 log: App name:myapp id:0 disconnected
myapp_1 | 2019-09-16T05:24:48: PM2 log: App [myapp:0] exited with code [0] via signal [SIGINT]
myapp_1 | 2019-09-16T05:24:48: PM2 log: App [myapp:0] starting in -cluster mode-
myapp_1 | 2019-09-16T05:24:48: PM2 log: App [myapp:0] online
myapp_1 | Error: Cannot find module 'express'
myapp_1 | at Function.Module._resolveFilename (module.js:476:15)
myapp_1 | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:51:29)
myapp_1 | at require (internal/module.js:20:19)
myapp_1 | at Object.<anonymous> (/usr/src/app/app.js:1:77)
myapp_1 | at Module._compile (module.js:577:32)
myapp_1 | at Object.Module._extensions..js (module.js:586:10)
myapp_1 | at Module.load (module.js:494:32)
myapp_1 | at tryModuleLoad (module.js:453:12)
myapp_1 | at Function.Module._load (module.js:445:3)
myapp_1 | at /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:295:23
myapp_1 | 2019-09-16T05:24:48: PM2 log: App name:myapp id:0 disconnected
myapp_1 | 2019-09-16T05:24:48: PM2 log: App [myapp:0] exited with code [0] via signal [SIGINT]
myapp_1 | 2019-09-16T05:24:48: PM2 log: App [myapp:0] starting in -cluster mode-
myapp_1 | 2019-09-16T05:24:48: PM2 log: App [myapp:0] online
myapp_1 | Error: Cannot find module 'express'
myapp_1 | at Function.Module._resolveFilename (module.js:476:15)
myapp_1 | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:51:29)
myapp_1 | at require (internal/module.js:20:19)
myapp_1 | at Object.<anonymous> (/usr/src/app/app.js:1:77)
myapp_1 | at Module._compile (module.js:577:32)
myapp_1 | at Object.Module._extensions..js (module.js:586:10)
myapp_1 | at Module.load (module.js:494:32)
myapp_1 | at tryModuleLoad (module.js:453:12)
myapp_1 | at Function.Module._load (module.js:445:3)
myapp_1 | at /usr/local/lib/node_modules/pm2/lib/ProcessContainer.js:295:23
myapp_1 | 2019-09-16T05:24:49: PM2 log: App name:myapp id:0 disconnected
myapp_1 | 2019-09-16T05:24:49: PM2 log: App [myapp:0] exited with code [0] via signal [SIGINT]
myapp_1 | 2019-09-16T05:24:49: PM2 log: Script /usr/src/app/app.js had too many unstable restarts (16). Stopped. "errored"
myapp_1 | 2019-09-16T05:24:51: PM2 log: 0 application online, retry = 3
myapp_1 | 2019-09-16T05:24:53: PM2 log: 0 application online, retry = 2
myapp_1 | 2019-09-16T05:24:55: PM2 log: 0 application online, retry = 1
myapp_1 | 2019-09-16T05:24:57: PM2 log: 0 application online, retry = 0
myapp_1 | 2019-09-16T05:24:57: PM2 log: Stopping app:myapp id:0
myapp_1 | 2019-09-16T05:24:57: PM2 error: app=myapp id=0 does not have a pid
myapp_1 | 2019-09-16T05:24:57: PM2 log: PM2 successfully stopped
nodejs-mongo-docker-sample_myapp_1 exited with code 2
database_1 | 2019-09-16T05:29:46.102+0000 I SHARDING [LogicalSessionCacheReap] Marking collection config.transactions as collection version: <unsharded>
...
耐著性子解析吧
Creating network "nodejs-mongo-docker-sample_default" with the default driver
不知道
Building myapp
這應該是因為 docker-compose.yml
裡
version: '2'
# Define the services/containers to be run
services:
myapp: #name of your service
build: ./ # specify the directory of the Dockerfile
ports:
- "3000:3000" #specify ports forwarding
links:
- database # link this service to the database service
volumes:
- .:/usr/src/app
depends_on:
- database
database: # name of the service
image: mongo # specify image to build container from
myapp 裡的 build 為 ./
的關係
所以會去找 ./Dockerfile
FROM node:boron
WORKDIR /usr/src/app
COPY package.json /usr/src/app
COPY package-lock.json /usr/src/app
RUN npm install
RUN npm install pm2 -g
COPY . /usr/src/app
EXPOSE 3000
CMD ["pm2-docker", "start", "process.json"]
可以對應到 step 1 ~ 9
Step 1/9 : FROM node:boron
boron: Pulling from library/node
c5e155d5a1d1: Pull complete
221d80d00ae9: Pull complete
4250b3117dca: Pull complete
3b7ca19181b2: Pull complete
425d7b2a5bcc: Pull complete
69df12c70287: Pull complete
ea2f5386a42d: Pull complete
d421d2b3c5eb: Pull complete
Digest: sha256:e133e66ec3bfc98da0440e552f452e5cdf6413319d27a2db3b01ac4b319759b3
Status: Downloaded newer image for node:boron
---> ab290b853066
Step 2/9 : WORKDIR /usr/src/app
Removing intermediate container 0c1358c1e5b2
---> 5a6b9ba481bb
Step 3/9 : COPY package.json /usr/src/app
---> ceb9a8b63f12
Step 4/9 : COPY package-lock.json /usr/src/app
---> 91bfb4cbab82
Step 5/9 : RUN npm install
---> Running in da70a1cf3f1f
> [email protected] postinstall /usr/src/app/node_modules/core-js
> node scripts/postinstall || echo "ignore"
[email protected] /usr/src/app
...
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
Removing intermediate container da70a1cf3f1f
---> 04bc71474586
Step 6/9 : RUN npm install pm2 -g
---> Running in 1c4ead5d3c36
/usr/local/bin/pm2 -> /usr/local/lib/node_modules/pm2/bin/pm2
/usr/local/bin/pm2-dev -> /usr/local/lib/node_modules/pm2/bin/pm2-dev
/usr/local/bin/pm2-runtime -> /usr/local/lib/node_modules/pm2/bin/pm2-runtime
/usr/local/bin/pm2-docker -> /usr/local/lib/node_modules/pm2/bin/pm2-docker
/usr/local/lib
...
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/pm2/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
Removing intermediate container 1c4ead5d3c36
---> b074faa5290c
Step 7/9 : COPY . /usr/src/app
---> 659dccbacc44
Step 8/9 : EXPOSE 3000
---> Running in b1ff8625d85a
Removing intermediate container b1ff8625d85a
---> b45725dd55d2
Step 9/9 : CMD ["pm2-docker", "start", "process.json"]
---> Running in 87d97b2b8f2b
...
覺得自己應該找比教簡單的 docker-compose 來玩玩看
Let’s Dockerize a Nodejs Express API
範例都跑得起來
不過在 docker-compose.yml
示範 volumes
時我並沒有發現該作者預期的行為
Docker - 容器化 Node.js express(Mac)
這個範例也蠻簡單的
找一下利用 node express 和 mongoose 互動的範例
- Dockerize a Node.js app connected to MongoDb
- Docker – Beginner’s Guide – Part 2: Services
- Docker-compose an express and mongo App
回歸基本面先再熟悉一下 express