ikkeT no sorry, I don't have this published publicly but perhaps I'll throw something up and update this post later on. The entrypoint is defined in the Dockerfile itself which I now realize is a script I made and you'd need that so here it is! Again though, I'm using the queue extension and not redis but works just fine for me so you will need to adapt for redis if you go that path.
Originally I used the single image to invoke either the scheduler, or queue directly and ran them both (before Queue supported being invoked by scheduler) so now the worker type should only be scheduler in your Kubernetes deployment container args.
kind: Deployment
...
spec:
...
args:
- '--worker-type=scheduler'
entrypoint.sh
#!/bin/bash
VALID_ARGS=$(getopt -o w:q:s: --long worker-type:,queue-memory:,queue-sleep:,queue-tries: -- "$@")
if [[ $? -ne 0 ]]; then
exit 1;
fi
eval set -- "$VALID_ARGS"
ARG_WORKER_TYPE=""
ARG_QUEUE_MEMORY=256
ARG_QUEUE_SLEEP=10
ARG_QUEUE_TRIES=3
while [ : ]; do
case "$1" in
-w | --worker-type)
ARG_WORKER_TYPE=$2
echo "argument 'worker-type' set to '$ARG_WORKER_TYPE'"
shift 2
;;
-m | --queue-memory)
ARG_QUEUE_MEMORY=$2
echo "argument 'queue-memory' set to '$ARG_QUEUE_MEMORY'"
shift 2
;;
-s | --queue-sleep)
ARG_QUEUE_SLEEP=$2
echo "argument 'queue-sleep' set to '$ARG_QUEUE_SLEEP'"
shift 2
;;
-t | --queue-tries)
ARG_QUEUE_TRIES=$2
echo "argument 'queue-tries' set to '$ARG_QUEUE_TRIES'"
shift 2
;;
--) shift;
break
;;
esac
done
case "$ARG_WORKER_TYPE" in
queue)
echo "starting flarum queue"
php /usr/share/nginx/flarum/flarum queue:work --sleep=$ARG_QUEUE_SLEEP --tries=$ARG_QUEUE_TRIES --memory=$ARG_QUEUE_MEMORY
;;
scheduler)
echo "starting flarum scheduler via supercronic"
supercronic /scheduler.cron
;;
*)
echo "worker type must be set"
sleep 10
exit 1
break
;;
esac
scheduler.cron
*/1 * * * * cd /usr/share/nginx/flarum && php flarum schedule:run >> /dev/null 2>&1
nginx.conf
# /etc/nginx/nginx.conf
#user nginx;
pid /var/run/pids/nginx.pid;
# Set number of worker processes automatically based on number of CPU cores.
worker_processes 1;
# Configures default error logger.
error_log /dev/stdout warn;
# Includes files with directives to load dynamic modules.
include /etc/nginx/modules/*.conf;
events {
# The maximum number of simultaneous connections that can be opened by
# a worker process.
worker_connections 10000;
multi_accept on;
# Preferred connection method for newer linux versions.
# Essential for linux, optmized to serve many clients with each thread.
#
use epoll;
}
worker_rlimit_nofile 102400;
http {
# Includes mapping of file name extensions to MIME types of responses
# and defines the default type.
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Name servers used to resolve names of upstream servers into addresses.
# It's also needed when using tcpsocket and udpsocket in Lua modules.
#resolver 208.67.222.222 208.67.220.220;
# Don't tell nginx version to clients.
server_tokens off;
# Specifies the maximum accepted body size of a client request, as
# indicated by the request header Content-Length. If the stated content
# length is greater than this size, then the client receives the HTTP
# error code 413. Set to 0 to disable.
client_max_body_size 200m;
# proxy timeout - php
#proxy_connect_timeout 660s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
fastcgi_send_timeout 600s;
fastcgi_read_timeout 600s;
#uwsgi_read_timeout 660s;
#uwsgi_connect_timeout 660s;
#fastcgi_buffers 16 16k;
#fastcgi_buffer_size 32k;
#proxy_buffer_size 128k;
#proxy_buffers 4 256k;
#proxy_busy_buffers_size 256k;
proxy_http_version 1.1;
proxy_set_header Connection "";
# Cache
fastcgi_cache_path /dev/shm levels=1:2 keys_zone=ocp:16m inactive=60m max_size=256m;
fastcgi_cache_key "$scheme$request_method$host$request_uri$query_string";
# Timeout for keep-alive connections. Server will close connections after
# this time.
keepalive_timeout 300;
keepalive_requests 500;
# Sendfile copies data between one FD and other from within the kernel,
# which is more efficient than read() + write().
sendfile on;
# Don't buffer data-sends (disable Nagle algorithm).
# Good for sending frequent small bursts of data in real time.
tcp_nodelay on;
# Causes nginx to attempt to send its HTTP response head in one packet,
# instead of using partial frames.
tcp_nopush on;
# Path of the file with Diffie-Hellman parameters for EDH ciphers.
#ssl_dhparam /etc/ssl/nginx/dh2048.pem;
# Specifies that our cipher suits should be preferred over client ciphers.
ssl_prefer_server_ciphers on;
# Enables a shared SSL cache with size that can hold around 8000 sessions.
ssl_session_cache shared:SSL:2m;
# Compression
# Enable Gzip compressed.
gzip on;
# Enable compression both for HTTP/1.0 and HTTP/1.1.
gzip_http_version 1.1;
# Compression level (1-9).
# 5 is a perfect compromise between size and cpu usage, offering about
# 75% reduction for most ascii files (almost identical to level 9).
gzip_comp_level 5;
# Don't compress anything that's already small and unlikely to shrink much
# if at all (the default is 20 bytes, which is bad as that usually leads to
# larger files after gzipping).
gzip_min_length 256;
# Compress data even for clients that are connecting to us via proxies,
# identified by the "Via" header (required for CloudFront).
gzip_proxied any;
# Tell proxies to cache both the gzipped and regular version of a resource
# whenever the client's Accept-Encoding capabilities header varies;
# Avoids the issue where a non-gzip capable client (which is extremely rare
# today) would display gibberish if their proxy gave them the gzipped version.
gzip_vary on;
# Compress all output labeled with one of the following MIME-types.
gzip_types
application/atom+xml
application/javascript
application/json
application/rss+xml
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/svg+xml
image/x-icon
text/css
text/plain
text/x-component;
# text/html is always compressed by HttpGzipModule
# Specifies the main log format.
log_format main '$remote_addr - "$http_x_forwarded_for" - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent"';
# Sets the path, format, and configuration for a buffered log write.
access_log /dev/stdout main;
# Includes virtual hosts configs.
include /etc/nginx/conf.d/*.conf;
}
flarum.conf (nginx)
server {
#proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
client_max_body_size 500M;
client_body_timeout 120s;
listen 8080 ssl http2;
## modify to your liking based on your host
server_name community.*;
## modify based on your certificate
ssl_certificate /etc/ssl/certs/tls.crt;
ssl_certificate_key /etc/ssl/certs/tls.key;
client_body_temp_path /var/tmp/nginx/client_temp 1 2;
proxy_temp_path /var/tmp/nginx/proxy_temp 1 2;
fastcgi_temp_path /var/tmp/nginx/fastcgi_temp 1 2;
uwsgi_temp_path /var/tmp/nginx/uwsgi_temp 1 2;
scgi_temp_path /var/tmp/nginx/scgi_temp 1 2;
# prevent redirect to listening port in URI
port_in_redirect off;
index index.php;
root /usr/share/nginx/flarum/public;
# Uncomment the following lines if you are not using a `public` directory
# to prevent sensitive resources from being exposed.
# location ~* ^/(\.git|composer\.(json|lock)|auth\.json|config\.php|flarum|storage|vendor) {
# deny all;
# return 404;
# }
# Pass requests that don't refer directly to files in the filesystem to index.php
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# The following directives are based on best practices from H5BP Nginx Server Configs
# https://github.com/h5bp/server-configs-nginx
# Expire rules for static content
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
add_header Cache-Control "max-age=0";
}
location ~* \.(?:rss|atom)$ {
add_header Cache-Control "max-age=3600";
}
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|mp4|ogg|ogv|webm|htc)$ {
add_header Cache-Control "max-age=2592000";
access_log off;
}
location ~* \.(?:css|js)$ {
add_header Cache-Control "max-age=31536000";
access_log off;
}
location ~* \.(?:ttf|ttc|otf|eot|woff|woff2)$ {
add_header "Access-Control-Allow-Origin" "*";
add_header Cache-Control "max-age=2592000";
access_log off;
}
location ~ \.php$ {
# add fastcgi_pass line here, depending if you use socket or port
include fastcgi_params;
fastcgi_read_timeout 660s;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}
}