Skip to content

Commit

Permalink
adding docs for init-wrapper script
Browse files Browse the repository at this point in the history
  • Loading branch information
pacostas committed Nov 22, 2022
1 parent d404db7 commit cf13d07
Show file tree
Hide file tree
Showing 6 changed files with 251 additions and 1 deletion.
41 changes: 41 additions & 0 deletions 14-minimal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,47 @@ Below is an example _package.json_ file with the _main_ attribute and _start_ sc
#### Note:
`oc rsync` is only available in versions 3.1+ of OpenShift.

## init-wrapper

init-wrapper script is located on `/usr/libexec/s2i/init-wrapper` and is used for preventing below circumstances:

- Proper signal handling and propagation, as Node.js was not designed to run as PID 1.
- Reaping zombie child processes
- Avoiding use of npm, more information on [reference architecture](https://github.com/nodeshift/nodejs-reference-architecture/blob/e4c4dc1fd20c2cac392e862859aaad27f85d504f/docs/development/building-good-containers.md#avoiding-using-npm-to-start-application)

A detailed explanation on how the init-wrapper script works is avalable on [this url](http://veithen.io/2014/11/16/sigterm-propagation.html).

Example of using init-wrapper:

**During image build**
```
s2i -e INIT_WRAPPER=true build . buildImage node-app
docker run node-app
```
**During container start**
```
s2i build . buildImage node-app
docker run -e INIT_WRAPPER=true node-app
```

`init-wrapper` script can be disabled by setting the `INIT_WRAPPER` env variable to `false`.

```
docker run -e INIT_WRAPPER=false node-app
```
`NODE_CMD` can be used during the build process or container start, in order to have more control on the command that `init-wrapper` script will wrap.

For example:

**during container build**
```
s2i -e INIT_WRAPPER=true -e NODE_CMD="node index.js" build . buildImage node-app
```
**during container start**
```
docker run -e INIT_WRAPPER=false -e NODE_CMD="node index.js" node-app
```

See also
--------
Expand Down
47 changes: 46 additions & 1 deletion 14/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ Application developers can use the following environment variables to configure
Select an alternate / custom runtime mode, defined in your `package.json` file's [`scripts`](https://docs.npmjs.com/misc/scripts) section (default: npm run "start"). These user-defined run-scripts are unavailable while `DEV_MODE` is in use.

**`NODE_CMD`**
When specified (e.g.Specify `NODE_CMD="node server.js"`) the `NODE_CMD` is executed by the `init-wrapper` script, which handles reaping zombie processes and signal forwarding (SIGINT, SIGTERM) to Node.js application.
When specified e.g. `NODE_CMD="node server.js"` the application will start by using the command `node server.js`.

**`HTTP_PROXY`**
Use an npm proxy during assembly
Expand All @@ -154,6 +154,10 @@ Application developers can use the following environment variables to configure
**`NPM_MIRROR`**
Use a custom NPM registry mirror to download packages during the build process

**`INIT_WRAPPER`**
When set to "true", it will look for the files `server.js`, `index.js` or `main.js` in the aforementioned order and in case any of these files are available, it will wrap the command `node $file_found`, by using the `init-wrapper` script.
It can also be used in conjuction with `NODE_CMD` option where in that case, `init-wrapper` will wrap the value of `NODE_CMD`.

One way to define a set of environment variables is to include them as key value pairs in your repo's `.s2i/environment` file.

Example: DATABASE_USER=sampleUser
Expand Down Expand Up @@ -244,6 +248,47 @@ Below is an example _package.json_ file with the _main_ attribute and _start_ sc
#### Note:
`oc rsync` is only available in versions 3.1+ of OpenShift.

## init-wrapper

init-wrapper script is located on `/usr/libexec/s2i/init-wrapper` and is used for preventing below circumstances:

- Proper signal handling and propagation, as Node.js was not designed to run as PID 1.
- Reaping zombie child processes
- Avoiding use of npm, more information on [reference architecture](https://github.com/nodeshift/nodejs-reference-architecture/blob/e4c4dc1fd20c2cac392e862859aaad27f85d504f/docs/development/building-good-containers.md#avoiding-using-npm-to-start-application)

A detailed explanation on how the init-wrapper script works is avalable on [this url](http://veithen.io/2014/11/16/sigterm-propagation.html).

Example of using init-wrapper:

**During image build**
```
s2i -e INIT_WRAPPER=true build . buildImage node-app
docker run node-app
```
**During container start**
```
s2i build . buildImage node-app
docker run -e INIT_WRAPPER=true node-app
```

`init-wrapper` script can be disabled by setting the `INIT_WRAPPER` env variable to `false`.

```
docker run -e INIT_WRAPPER=false node-app
```
`NODE_CMD` can be used during the build process or container start, in order to have more control on the command that `init-wrapper` script will wrap.

For example:

**during container build**
```
s2i -e INIT_WRAPPER=true -e NODE_CMD="node index.js" build . buildImage node-app
```
**during container start**
```
docker run -e INIT_WRAPPER=false -e NODE_CMD="node index.js" node-app
```

See also
--------
Expand Down
41 changes: 41 additions & 0 deletions 16-minimal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,47 @@ Below is an example _package.json_ file with the _main_ attribute and _start_ sc
#### Note:
`oc rsync` is only available in versions 3.1+ of OpenShift.

## init-wrapper

init-wrapper script is located on `/usr/libexec/s2i/init-wrapper` and is used for preventing below circumstances:

- Proper signal handling and propagation, as Node.js was not designed to run as PID 1.
- Reaping zombie child processes
- Avoiding use of npm, more information on [reference architecture](https://github.com/nodeshift/nodejs-reference-architecture/blob/e4c4dc1fd20c2cac392e862859aaad27f85d504f/docs/development/building-good-containers.md#avoiding-using-npm-to-start-application)

A detailed explanation on how the init-wrapper script works is avalable on [this url](http://veithen.io/2014/11/16/sigterm-propagation.html).

Example of using init-wrapper:

**During image build**
```
s2i -e INIT_WRAPPER=true build . buildImage node-app
docker run node-app
```
**During container start**
```
s2i build . buildImage node-app
docker run -e INIT_WRAPPER=true node-app
```

`init-wrapper` script can be disabled by setting the `INIT_WRAPPER` env variable to `false`.

```
docker run -e INIT_WRAPPER=false node-app
```
`NODE_CMD` can be used during the build process or container start, in order to have more control on the command that `init-wrapper` script will wrap.

For example:

**during container build**
```
s2i -e INIT_WRAPPER=true -e NODE_CMD="node index.js" build . buildImage node-app
```
**during container start**
```
docker run -e INIT_WRAPPER=false -e NODE_CMD="node index.js" node-app
```

See also
--------
Expand Down
41 changes: 41 additions & 0 deletions 16/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,47 @@ Below is an example _package.json_ file with the _main_ attribute and _start_ sc
#### Note:
`oc rsync` is only available in versions 3.1+ of OpenShift.

## init-wrapper

init-wrapper script is located on `/usr/libexec/s2i/init-wrapper` and is used for preventing below circumstances:

- Proper signal handling and propagation, as Node.js was not designed to run as PID 1.
- Reaping zombie child processes
- Avoiding use of npm, more information on [reference architecture](https://github.com/nodeshift/nodejs-reference-architecture/blob/e4c4dc1fd20c2cac392e862859aaad27f85d504f/docs/development/building-good-containers.md#avoiding-using-npm-to-start-application)

A detailed explanation on how the init-wrapper script works is avalable on [this url](http://veithen.io/2014/11/16/sigterm-propagation.html).

Example of using init-wrapper:

**During image build**
```
s2i -e INIT_WRAPPER=true build . buildImage node-app
docker run node-app
```
**During container start**
```
s2i build . buildImage node-app
docker run -e INIT_WRAPPER=true node-app
```

`init-wrapper` script can be disabled by setting the `INIT_WRAPPER` env variable to `false`.

```
docker run -e INIT_WRAPPER=false node-app
```
`NODE_CMD` can be used during the build process or container start, in order to have more control on the command that `init-wrapper` script will wrap.

For example:

**during container build**
```
s2i -e INIT_WRAPPER=true -e NODE_CMD="node index.js" build . buildImage node-app
```
**during container start**
```
docker run -e INIT_WRAPPER=false -e NODE_CMD="node index.js" node-app
```

See also
--------
Expand Down
41 changes: 41 additions & 0 deletions 18-minimal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,47 @@ Below is an example _package.json_ file with the _main_ attribute and _start_ sc
#### Note:
`oc rsync` is only available in versions 3.1+ of OpenShift.

## init-wrapper

init-wrapper script is located on `/usr/libexec/s2i/init-wrapper` and is used for preventing below circumstances:

- Proper signal handling and propagation, as Node.js was not designed to run as PID 1.
- Reaping zombie child processes
- Avoiding use of npm, more information on [reference architecture](https://github.com/nodeshift/nodejs-reference-architecture/blob/e4c4dc1fd20c2cac392e862859aaad27f85d504f/docs/development/building-good-containers.md#avoiding-using-npm-to-start-application)

A detailed explanation on how the init-wrapper script works is avalable on [this url](http://veithen.io/2014/11/16/sigterm-propagation.html).

Example of using init-wrapper:

**During image build**
```
s2i -e INIT_WRAPPER=true build . buildImage node-app
docker run node-app
```
**During container start**
```
s2i build . buildImage node-app
docker run -e INIT_WRAPPER=true node-app
```

`init-wrapper` script can be disabled by setting the `INIT_WRAPPER` env variable to `false`.

```
docker run -e INIT_WRAPPER=false node-app
```
`NODE_CMD` can be used during the build process or container start, in order to have more control on the command that `init-wrapper` script will wrap.

For example:

**during container build**
```
s2i -e INIT_WRAPPER=true -e NODE_CMD="node index.js" build . buildImage node-app
```
**during container start**
```
docker run -e INIT_WRAPPER=false -e NODE_CMD="node index.js" node-app
```

See also
--------
Expand Down
41 changes: 41 additions & 0 deletions 18/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,47 @@ Below is an example _package.json_ file with the _main_ attribute and _start_ sc
#### Note:
`oc rsync` is only available in versions 3.1+ of OpenShift.

## init-wrapper

init-wrapper script is located on `/usr/libexec/s2i/init-wrapper` and is used for preventing below circumstances:

- Proper signal handling and propagation, as Node.js was not designed to run as PID 1.
- Reaping zombie child processes
- Avoiding use of npm, more information on [reference architecture](https://github.com/nodeshift/nodejs-reference-architecture/blob/e4c4dc1fd20c2cac392e862859aaad27f85d504f/docs/development/building-good-containers.md#avoiding-using-npm-to-start-application)

A detailed explanation on how the init-wrapper script works is avalable on [this url](http://veithen.io/2014/11/16/sigterm-propagation.html).

Example of using init-wrapper:

**During image build**
```
s2i -e INIT_WRAPPER=true build . buildImage node-app
docker run node-app
```
**During container start**
```
s2i build . buildImage node-app
docker run -e INIT_WRAPPER=true node-app
```

`init-wrapper` script can be disabled by setting the `INIT_WRAPPER` env variable to `false`.

```
docker run -e INIT_WRAPPER=false node-app
```
`NODE_CMD` can be used during the build process or container start, in order to have more control on the command that `init-wrapper` script will wrap.

For example:

**during container build**
```
s2i -e INIT_WRAPPER=true -e NODE_CMD="node index.js" build . buildImage node-app
```
**during container start**
```
docker run -e INIT_WRAPPER=false -e NODE_CMD="node index.js" node-app
```

See also
--------
Expand Down

0 comments on commit cf13d07

Please sign in to comment.