translate 8-2 to japanese

This commit is contained in:
Yuta Azumi
2020-12-23 21:51:01 +09:00
parent f257961ce0
commit 924595b49d
2 changed files with 15 additions and 15 deletions

View File

@ -1111,13 +1111,13 @@ CMD [ "node", "dist/app.js" ]
<br /><br /><br />
## ![✔] 8.2. Bootstrap using 'node' command, avoid npm start
## ![✔] 8.2. Bootstrap node' コマンドを使用して、npm start 避ける
**TL;DR:** use `CMD ['node','server.js']` to start your app, avoid using npm scripts which don't pass OS signals to the code. This prevents problems with child-process, signal handling, graceful shutdown and having zombie processes.
**TL;DR:** アプリの起動には `CMD ['node','server.js']` を使用し、OS のシグナルをコードに渡さない npm スクリプトの使用は避けてください。これにより、子プロセス、シグナル処理、グレースフルシャットダウン、ゾンビプロセスの問題を防ぐことができます。
**Otherwise:** When no signals are passed, your code will never be notified about shutdowns. Without this, it will lose its chance to close properly possibly losing current requests and/or data.
**さもないと:** シグナルが通らない場合、あなたのコードはシャットダウンについて通知されることはありません。これがなければ、適切に閉じる機会を失い、現在のリクエストやデータを失う可能性があります。
[**Read More: Bootstrap container using node command, avoid npm start**](/sections/docker/bootstrap-using-node.md)
[**さらに読む: Bootstrap コンテナは node コマンドを使用して 、npm の起動を避ける**](/sections/docker/bootstrap-using-node.japanese.md)
<br /><br /><br />

View File

@ -1,10 +1,10 @@
# Bootstrap container using node command instead of npm
# npm の代わりに node コマンドを使用した Bootstrap コンテナ
## One paragraph explainer
## 一段落説明
We are used to see code examples where folks start their app using `CMD 'npm start'`. This is a bad practice. The `npm` binary will not forward signals to your app which prevents graceful shutdown (see [/sections/docker/graceful-shutdown.md]). If you are using Child-processes they wont be cleaned up correctly in case of unexpected shutdown, leaving zombie processes on your host. `npm start` also results in having an extra process for no benefit. To start you app use `CMD ['node','server.js']`. If your app spawns child-processes also use `TINI` as an entrypoint.
`CMD 'npm start'`を使ってアプリを起動するコード例をよく見かけます。 This is a bad practice. The `npm` binary will not forward signals to your app which prevents graceful shutdown (see [/sections/docker/graceful-shutdown.md]). If you are using Child-processes they wont be cleaned up correctly in case of unexpected shutdown, leaving zombie processes on your host. `npm start` also results in having an extra process for no benefit. To start you app use `CMD ['node','server.js']`. If your app spawns child-processes also use `TINI` as an entrypoint.
### Code example - Bootsraping using Node
### コード例 - node を使用した Bootsraping
```dockerfile
@ -19,7 +19,7 @@ CMD ["node", "server.js"]
```
### Code example - Using Tiny as entrypoint
### コード例 - エントリーポイントとしての Tiny の使用
```dockerfile
@ -39,7 +39,7 @@ ENTRYPOINT ["/tini", "--"]
CMD ["node", "server.js"]
```
### Antipatterns
### アンチパターン
Using npm start
```dockerfile
@ -49,7 +49,7 @@ WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm ci --production && npm clean cache --force
# dont do that!
# これはしないでください!
CMD "npm start"
```
@ -62,11 +62,11 @@ WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm ci --production && npm clean cache --force
# dont do that, it will start bash
# これはしないでください、バッシングが始まります
CMD "node server.js"
```
Starting with npm, heres the process tree:
npm でスタートすると、プロセスツリーは以下のようになります。:
```
$ ps falx
UID PID PPID COMMAND
@ -74,9 +74,9 @@ $ ps falx
0 16 1 sh -c node server.js
0 17 16 \_ node server.js
```
There is no advantage to those two extra process.
その2つの余分なプロセスには何のメリットもありません。
Sources:
ソース:
https://maximorlov.com/process-signals-inside-docker-containers/