Skip to content

Commit 2a4a359

Browse files
authored
Merge pull request #24 from linuxserver/develop-sidekiq
2 parents 0d1330b + 8dab490 commit 2a4a359

10 files changed

Lines changed: 93 additions & 11 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Comment on invalid interaction
2+
on:
3+
issues:
4+
types:
5+
- labeled
6+
jobs:
7+
add-comment-on-invalid:
8+
if: github.event.label.name == 'invalid'
9+
permissions:
10+
issues: write
11+
uses: linuxserver/github-workflows/.github/workflows/invalid-interaction-helper.yml@v1
12+
secrets: inherit

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# syntax=docker/dockerfile:1
2+
13
FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.15
24

35
ARG BUILD_DATE

Dockerfile.aarch64

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# syntax=docker/dockerfile:1
2+
13
FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm64v8-3.15
24

35
ARG BUILD_DATE

Dockerfile.armhf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# syntax=docker/dockerfile:1
2+
13
FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm32v7-3.15
24

35
ARG BUILD_DATE

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ We support all of the official [environment variables](https://docs.joinmastodon
8080

8181
For more information check out the [mastodon documentation](https://docs.joinmastodon.org/).
8282

83+
### Running separate sidekiq instances
84+
85+
It is currently only supported to run a single queue per container instance *or* all queues in a single container instance.
86+
87+
All containers must share the same `/config`` mount and be on a common docker network.
88+
8389
### Strict reverse proxies
8490

8591
This image automatically redirects to https with a self-signed certificate. If you are using a reverse proxy which validates certificates, you need to [disable this check for the container](https://docs.linuxserver.io/faq#strict-proxy).
@@ -129,6 +135,11 @@ services:
129135
- AWS_ACCESS_KEY_ID= #optional
130136
- AWS_SECRET_ACCESS_KEY= #optional
131137
- S3_ALIAS_HOST= #optional
138+
- SIDEKIQ_ONLY=false #optional
139+
- SIDEKIQ_QUEUE= #optional
140+
- SIDEKIQ_DEFAULT=false #optional
141+
- SIDEKIQ_THREADS=5 #optional
142+
- DB_POOL=5 #optional
132143
volumes:
133144
- /path/to/appdata/config:/config
134145
ports:
@@ -173,6 +184,11 @@ docker run -d \
173184
-e AWS_ACCESS_KEY_ID= `#optional` \
174185
-e AWS_SECRET_ACCESS_KEY= `#optional` \
175186
-e S3_ALIAS_HOST= `#optional` \
187+
-e SIDEKIQ_ONLY=false `#optional` \
188+
-e SIDEKIQ_QUEUE= `#optional` \
189+
-e SIDEKIQ_DEFAULT=false `#optional` \
190+
-e SIDEKIQ_THREADS=5 `#optional` \
191+
-e DB_POOL=5 `#optional` \
176192
-p 80:80 \
177193
-p 443:443 \
178194
-v /path/to/appdata/config:/config \
@@ -219,6 +235,11 @@ Container images are configured using parameters passed at runtime (such as thos
219235
| `-e AWS_ACCESS_KEY_ID=` | S3 bucket access key ID |
220236
| `-e AWS_SECRET_ACCESS_KEY=` | S3 bucket secret access key |
221237
| `-e S3_ALIAS_HOST=` | Alternate hostname for object fetching if you are front the S3 connections. |
238+
| `-e SIDEKIQ_ONLY=false` | Only run the sidekiq service in this container instance. For large scale instances that need better queue handling. |
239+
| `-e SIDEKIQ_QUEUE=` | The name of the sidekiq queue to run in this container. See [notes](https://docs.joinmastodon.org/admin/scaling/#sidekiq-queues). |
240+
| `-e SIDEKIQ_DEFAULT=false` | Set to `true` on the main container if you're running additional sidekiq instances. It will run the `default` queue. |
241+
| `-e SIDEKIQ_THREADS=5` | The number of threads for sidekiq to use. See [notes](https://docs.joinmastodon.org/admin/scaling/#sidekiq-threads). |
242+
| `-e DB_POOL=5` | The size of the DB connection pool, must be *at least* the same as `SIDEKIQ_THREADS`. See [notes](https://docs.joinmastodon.org/admin/scaling/#sidekiq-threads). |
222243
| `-v /config` | Contains all relevant configuration files. |
223244

224245
## Environment variables from files (Docker secrets)
@@ -330,5 +351,6 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
330351

331352
## Versions
332353

354+
* **19.12.22:** - Support separate sidekiq queue instances.
333355
* **08.11.22:** - Add develop branch.
334356
* **05.11.22:** - Initial Release.

readme-vars.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ opt_param_env_vars:
5858
- { env_var: "AWS_ACCESS_KEY_ID", env_value: "", desc: "S3 bucket access key ID"}
5959
- { env_var: "AWS_SECRET_ACCESS_KEY", env_value: "", desc: "S3 bucket secret access key"}
6060
- { env_var: "S3_ALIAS_HOST", env_value: "", desc: "Alternate hostname for object fetching if you are front the S3 connections."}
61+
- { env_var: "SIDEKIQ_ONLY", env_value: "false", desc: "Only run the sidekiq service in this container instance. For large scale instances that need better queue handling."}
62+
- { env_var: "SIDEKIQ_QUEUE", env_value: "", desc: "The name of the sidekiq queue to run in this container. See [notes](https://docs.joinmastodon.org/admin/scaling/#sidekiq-queues)."}
63+
- { env_var: "SIDEKIQ_DEFAULT", env_value: "false", desc: "Set to `true` on the main container if you're running additional sidekiq instances. It will run the `default` queue."}
64+
- { env_var: "SIDEKIQ_THREADS", env_value: "5", desc: "The number of threads for sidekiq to use. See [notes](https://docs.joinmastodon.org/admin/scaling/#sidekiq-threads)."}
65+
- { env_var: "DB_POOL", env_value: "5", desc: "The size of the DB connection pool, must be *at least* the same as `SIDEKIQ_THREADS`. See [notes](https://docs.joinmastodon.org/admin/scaling/#sidekiq-threads)."}
6166

6267
param_usage_include_ports: true
6368
param_ports:
@@ -83,11 +88,18 @@ app_setup_block: |
8388
8489
For more information check out the [mastodon documentation](https://docs.joinmastodon.org/).
8590
91+
### Running separate sidekiq instances
92+
93+
It is currently only supported to run a single queue per container instance *or* all queues in a single container instance.
94+
95+
All containers must share the same `/config`` mount and be on a common docker network.
96+
8697
### Strict reverse proxies
8798
8899
This image automatically redirects to https with a self-signed certificate. If you are using a reverse proxy which validates certificates, you need to [disable this check for the container](https://docs.linuxserver.io/faq#strict-proxy).
89100
90101
# changelog
91102
changelogs:
103+
- { date: "19.12.22:", desc: "Support separate sidekiq queue instances." }
92104
- { date: "08.11.22:", desc: "Add develop branch." }
93-
- { date: "05.11.22:", desc: "Initial Release." }
105+
- { date: "05.11.22:", desc: "Initial Release." }

root/etc/cont-init.d/50-config

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
# Disable php-fpm service as Mastodon doesn't use it
55
touch /etc/services.d/php-fpm/down
66

7+
# Disable other services if this is a sidekiq-only container
8+
if [[ ${SIDEKIQ_ONLY,,} == "true" ]]; then
9+
touch /etc/services.d/mastodon/down
10+
touch /etc/services.d/streaming/down
11+
touch /etc/services.d/nginx/down
12+
fi
13+
714
mkdir -p \
815
/app/www/tmp \
916
/config/mastodon/public/system
@@ -15,7 +22,10 @@ ln -s /config/mastodon/public/system /app/www/public/system
1522

1623
cd /app/www/ || exit 1
1724

18-
s6-setuidgid abc /usr/bin/bundle exec rails db:prepare
25+
# Don't run DB prep if this is a sidekiq-only container
26+
if [[ ${SIDEKIQ_ONLY,,} != "true" ]]; then
27+
s6-setuidgid abc /usr/bin/bundle exec rails db:prepare
28+
fi
1929

2030
chown abc:abc \
2131
/config/mastodon/public/system

root/etc/services.d/mastodon/run

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/usr/bin/with-contenv bash
22
# shellcheck shell=bash
33

4-
RAILS_ENV=production
5-
PATH="${PATH}:/app/www/bin"
6-
RAILS_SERVE_STATIC_FILES=false
4+
export RAILS_ENV=production
5+
export PATH="${PATH}:/app/www/bin"
6+
export RAILS_SERVE_STATIC_FILES=false
77

88
exec \
99
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost 3000" \

root/etc/services.d/sidekiq/run

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
11
#!/usr/bin/with-contenv bash
22
# shellcheck shell=bash
33

4-
RAILS_ENV=production
5-
PATH="${PATH}:/app/www/bin"
4+
export RAILS_ENV=production
5+
export PATH="${PATH}:/app/www/bin"
6+
7+
if [[ -n ${SIDEKIQ_THREADS} ]]; then
8+
SIDEKIQ_THREADS=$(printf '%d' "${SIDEKIQ_THREADS}")
9+
else
10+
SIDEKIQ_THREADS=$(printf '%d' 5)
11+
fi
612

713
cd /app/www || exit 1
814

9-
exec \
10-
s6-setuidgid abc /usr/bin/bundle exec sidekiq
15+
if [[ ${SIDEKIQ_ONLY,,} == "true" ]] && [[ -n ${SIDEKIQ_QUEUE} ]]; then
16+
echo "*** Starting sidekiq handling ${SIDEKIQ_QUEUE} queue with ${SIDEKIQ_THREADS} threads ***"
17+
exec \
18+
s6-setuidgid abc /usr/bin/bundle exec sidekiq -q "${SIDEKIQ_QUEUE}" -c ${SIDEKIQ_THREADS}
19+
elif [[ ${SIDEKIQ_ONLY,,} == "true" ]] && [[ -z ${SIDEKIQ_QUEUE} ]]; then
20+
echo "*** No sidekiq queue specified, aborting ***"
21+
sleep infinity
22+
elif [[ ${SIDEKIQ_DEFAULT,,} == "true" ]]; then
23+
echo "*** Starting sidekiq handling default queue with ${SIDEKIQ_THREADS} threads ***"
24+
exec \
25+
s6-setuidgid abc /usr/bin/bundle exec sidekiq -q default -c ${SIDEKIQ_THREADS}
26+
else
27+
echo "*** Starting sidekiq handling all queues with ${SIDEKIQ_THREADS} threads ***"
28+
exec \
29+
s6-setuidgid abc /usr/bin/bundle exec sidekiq -c ${SIDEKIQ_THREADS}
30+
fi

root/etc/services.d/streaming/run

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/with-contenv bash
22
# shellcheck shell=bash
33

4-
NODE_ENV=production
5-
PATH="${PATH}:/app/www/bin"
4+
export NODE_ENV=production
5+
export PATH="${PATH}:/app/www/bin"
66

77
exec \
88
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost 4000" \

0 commit comments

Comments
 (0)