Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add python multiple processes article #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

runnabro
Copy link
Member

@runnabro runnabro commented Oct 13, 2016

Editor Comment:

Signal names (SIGINT and SIGTERM) are formatted as code in this article, but I have simply italicized them in the other markdown articles. Do you have a preference?

@runnabro runnabro changed the title add markdown article add python multiple processes article Oct 13, 2016

### Phusion base image

The simplest way to get started is to use [phusion-baseimage](https://github.com/phusion/baseimage-docker "https://github.com/phusion/baseimage-docker")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing period.

#### app1.sh
This is the runit script for our first app. We send the output to STDOUT so that the Docker logs can handle it. Without <a href="https://en.wikipedia.org/wiki/Shebang_(Unix)">shebang</a> (`#!/bin/sh`), the following error will occur: `runsv app1: fatal: unable to start ./run: exec format error`

Again, we send the output to STDOUT so that the Docker logs can handle it.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Colon?

```

#### app2.sh
App2 runit script
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing colon.

exec python /app2.py >> /dev/stdout 2>&1
```

#### Note for windows users:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an aside?

tags:
- docker
- python
excerpt: Although Docker best practices recommend running one application per container, you may need to run a multiprocess app or create a standalone multi-app Docker image.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit this down.


### 2. Signal handling

By default, PID1 ignores the interrupt `SIGINT` and the termination signal `SIGTERM`. In response to the `docker stop` command (which sends `SIGTERM` to your container's PID1), you must relay `SIGTERM` to all your running processes to terminate them cleanly.
Copy link
Member Author

@runnabro runnabro Oct 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Editor Comment:

The second sentence is unclear. Please review my changes to make sure the meaning has been preserved. In particular:

"...PID1 must relay this signal..."

Which signal?


If you do not need process supervision, you can use [tini](https://github.com/krallin/tini "https://github.com/krallin/tini") as a lightweight init process. Tini also handles signals.

[S6](http://skarnet.org/software/s6/ "http://skarnet.org/software/s6/") is a complete solution: a minimal process supervisor that also acts as an init process.
Copy link
Member Author

@runnabro runnabro Oct 13, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Editor Comment:

"...a minimal process supervisor..."

What does "minimal" mean in this context?

#### app1.sh
This is the runit script for our first app. We send the output to STDOUT so that the Docker logs can handle it. Without <a href="https://en.wikipedia.org/wiki/Shebang_(Unix)">shebang</a> (`#!/bin/sh`), the following error will occur: `runsv app1: fatal: unable to start ./run: exec format error`

Again, we send the output to STDOUT so that the Docker logs can handle it.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Editor Comment:

"We send the output to STDOUT so that the Docker logs can handle it."

What is "it"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant