-
Notifications
You must be signed in to change notification settings - Fork 76
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
Upkeep for Playground deployment #311
Changes from all commits
ec6a3e2
f58d948
428ea8b
08f75d0
8b2cb1a
005ed1f
2499fe2
ce8b5e4
253c22c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
--- | ||
|
||
# See this role's README for documentation about these defaults. | ||
worker_connections: 768 | ||
proxied: {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,13 @@ | |
src: after-ssl-renew.sh | ||
dest: /etc/ssl/letsencrypt/after-renew.d | ||
mode: 0750 | ||
|
||
- name: create systemd override file | ||
file: | ||
path: /etc/systemd/system/nginx.service.d | ||
state: directory | ||
|
||
- name: create systemd override file | ||
template: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ansible-lint suggests writing the FQDN name of the task: It's probably worth considering enforcing ansible-lint on the CI to have a consistent style everywhere. |
||
src: override.conf | ||
dest: /etc/systemd/system/nginx.service.d/override.conf |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[Service] | ||
# This assumes that the NGINX instance will usually be used as an | ||
# upstream proxy. Each incoming connection takes one FD for the client | ||
# and one FD for the proxy. We add a few extra FDs to account for | ||
# things like config and log files. | ||
LimitNOFILE={{ (worker_connections * 2) + 32 }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quick question: what's the equation for? This multiplication and addition. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment added |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[Service] | ||
Slice=playground.slice |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
{ | ||
"cgroup-parent": "playground.slice", | ||
"log-driver": "local", | ||
"storage-driver": "overlay2" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[Service] | ||
Slice=playground.slice |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# {{ ansible_managed }} | ||
# | ||
|
||
# {% raw %} | ||
|
||
set -euv -o pipefail | ||
|
||
# How long a container must be running to be killed. | ||
# Number of seconds. | ||
MAX_TIME=3600 | ||
|
||
now=$(date "+%s") | ||
to_kill=() | ||
|
||
readarray -t container_ids < <(docker ps --format '{{ .ID }}' --no-trunc) | ||
|
||
while read -r id started_at; do | ||
started_at=$(date --date "${started_at}" "+%s") | ||
running_time=$((now - started_at)) | ||
|
||
if [[ "${running_time}" -gt "${MAX_TIME}" ]]; then | ||
to_kill+=("${id}") | ||
fi | ||
done < <(docker inspect "${container_ids[@]}" --format '{{ .ID }} {{ .State.StartedAt }}') | ||
|
||
if [[ ${#to_kill[@]} -gt 0 ]]; then | ||
docker kill "${to_kill[@]}" | ||
fi | ||
|
||
# {% endraw %} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# | ||
# {{ ansible_managed }} | ||
# | ||
|
||
[Unit] | ||
Description=Garbage collect dead playground containers | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart={{ vars_playground_gc_path }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# | ||
# {{ ansible_managed }} | ||
# | ||
|
||
[Unit] | ||
Description = Garbage collect playground containers every 15 minutes | ||
|
||
[Timer] | ||
OnBootSec = 15min | ||
OnUnitActiveSec = 15min | ||
|
||
[Install] | ||
WantedBy = timers.target |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[Unit] | ||
Description=Resource management group for playground processes | ||
Before=slices.target |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this any different, I wonder? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check out the commit message