justinw
justinw
RRailway
Created by justinw on 6/6/2023 in #✋|help
Infinite worker boot/crash loop
true
112 replies
RRailway
Created by justinw on 6/6/2023 in #✋|help
Infinite worker boot/crash loop
ahh gotcha
112 replies
RRailway
Created by justinw on 6/6/2023 in #✋|help
Infinite worker boot/crash loop
full time employee
112 replies
RRailway
Created by justinw on 6/6/2023 in #✋|help
Infinite worker boot/crash loop
@Brody out of curosity are you a FTE at railway or is this volunteer discord?
112 replies
RRailway
Created by justinw on 6/6/2023 in #✋|help
Infinite worker boot/crash loop
access
112 replies
RRailway
Created by justinw on 6/6/2023 in #✋|help
Infinite worker boot/crash loop
gatekeeping
112 replies
RRailway
Created by justinw on 6/6/2023 in #✋|help
Infinite worker boot/crash loop
log_data = {
"loglevel": loglevel, "workers": workers, "bind": bind,
112 replies
RRailway
Created by justinw on 6/6/2023 in #✋|help
Infinite worker boot/crash loop
workers = web_concurrency
112 replies
RRailway
Created by justinw on 6/6/2023 in #✋|help
Infinite worker boot/crash loop
web_concurrency_str = os.getenv("WEB_CONCURRENCY", None)
112 replies
RRailway
Created by justinw on 6/6/2023 in #✋|help
Infinite worker boot/crash loop
yes
112 replies
RRailway
Created by justinw on 6/6/2023 in #✋|help
Infinite worker boot/crash loop
MAX_WORKERS is set to 3 on the railway config panel
112 replies
RRailway
Created by justinw on 6/6/2023 in #✋|help
Infinite worker boot/crash loop
import json
import multiprocessing
import os

workers_per_core_str = os.getenv("WORKERS_PER_CORE", "1")
max_workers_str = os.getenv("MAX_WORKERS")
use_max_workers = None
if max_workers_str:
use_max_workers = int(max_workers_str)
web_concurrency_str = os.getenv("WEB_CONCURRENCY", None)

host = os.getenv("HOST", "0.0.0.0")
port = os.getenv("PORT", "80")
bind_env = os.getenv("BIND", None)
use_loglevel = os.getenv("LOG_LEVEL", "debug")
if bind_env:
use_bind = bind_env
else:
use_bind = f"{host}:{port}"

cores = multiprocessing.cpu_count()
workers_per_core = float(workers_per_core_str)
default_web_concurrency = workers_per_core * cores
if web_concurrency_str:
web_concurrency = int(web_concurrency_str)
assert web_concurrency > 0
else:
web_concurrency = max(int(default_web_concurrency), 2)
if use_max_workers:
web_concurrency = min(web_concurrency, use_max_workers)
accesslog_var = os.getenv("ACCESS_LOG", "-")
access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s" [worker: %(p)s]'
use_accesslog = accesslog_var or None
errorlog_var = os.getenv("ERROR_LOG", "-")
use_errorlog = errorlog_var or None
graceful_timeout_str = os.getenv("GRACEFUL_TIMEOUT", "120")
timeout_str = os.getenv("TIMEOUT", "120")
keepalive_str = os.getenv("KEEP_ALIVE", "5")

# Gunicorn config variables
loglevel = use_loglevel
workers = web_concurrency
bind = use_bind
errorlog = use_errorlog
worker_tmp_dir = "/dev/shm"
accesslog = use_accesslog
graceful_timeout = int(graceful_timeout_str)
timeout = int(timeout_str)
keepalive = int(keepalive_str)


# For debugging and testing
log_data = {
"loglevel": loglevel,
"workers": workers,
"bind": bind,
"graceful_timeout": graceful_timeout,
"timeout": timeout,
"keepalive": keepalive,
"errorlog": errorlog,
"accesslog": accesslog,
# Additional, non-gunicorn variables
"workers_per_core": workers_per_core,
"use_max_workers": use_max_workers,
"host": host,
"port": port,
"limit_request_line": 0,
"limit_request_fields": 0,
"limit_request_field_size": 0,
"access_log_format": access_log_format,
}
print(json.dumps(log_data))
import json
import multiprocessing
import os

workers_per_core_str = os.getenv("WORKERS_PER_CORE", "1")
max_workers_str = os.getenv("MAX_WORKERS")
use_max_workers = None
if max_workers_str:
use_max_workers = int(max_workers_str)
web_concurrency_str = os.getenv("WEB_CONCURRENCY", None)

host = os.getenv("HOST", "0.0.0.0")
port = os.getenv("PORT", "80")
bind_env = os.getenv("BIND", None)
use_loglevel = os.getenv("LOG_LEVEL", "debug")
if bind_env:
use_bind = bind_env
else:
use_bind = f"{host}:{port}"

cores = multiprocessing.cpu_count()
workers_per_core = float(workers_per_core_str)
default_web_concurrency = workers_per_core * cores
if web_concurrency_str:
web_concurrency = int(web_concurrency_str)
assert web_concurrency > 0
else:
web_concurrency = max(int(default_web_concurrency), 2)
if use_max_workers:
web_concurrency = min(web_concurrency, use_max_workers)
accesslog_var = os.getenv("ACCESS_LOG", "-")
access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s" [worker: %(p)s]'
use_accesslog = accesslog_var or None
errorlog_var = os.getenv("ERROR_LOG", "-")
use_errorlog = errorlog_var or None
graceful_timeout_str = os.getenv("GRACEFUL_TIMEOUT", "120")
timeout_str = os.getenv("TIMEOUT", "120")
keepalive_str = os.getenv("KEEP_ALIVE", "5")

# Gunicorn config variables
loglevel = use_loglevel
workers = web_concurrency
bind = use_bind
errorlog = use_errorlog
worker_tmp_dir = "/dev/shm"
accesslog = use_accesslog
graceful_timeout = int(graceful_timeout_str)
timeout = int(timeout_str)
keepalive = int(keepalive_str)


# For debugging and testing
log_data = {
"loglevel": loglevel,
"workers": workers,
"bind": bind,
"graceful_timeout": graceful_timeout,
"timeout": timeout,
"keepalive": keepalive,
"errorlog": errorlog,
"accesslog": accesslog,
# Additional, non-gunicorn variables
"workers_per_core": workers_per_core,
"use_max_workers": use_max_workers,
"host": host,
"port": port,
"limit_request_line": 0,
"limit_request_fields": 0,
"limit_request_field_size": 0,
"access_log_format": access_log_format,
}
print(json.dumps(log_data))
112 replies
RRailway
Created by justinw on 6/6/2023 in #✋|help
Infinite worker boot/crash loop
one sec grabbing the config
112 replies
RRailway
Created by justinw on 6/6/2023 in #✋|help
Infinite worker boot/crash loop
export GUNICORN_CONF=${GUNICORN_CONF:-$DEFAULT_GUNICORN_CONF}
112 replies
RRailway
Created by justinw on 6/6/2023 in #✋|help
Infinite worker boot/crash loop
export WORKER_CLASS=${WORKER_CLASS:-"uvicorn.workers.UvicornWorker"} gunicorn --worker-class "$WORKER_CLASS" --config "$GUNICORN_CONF" "$APP_MODULE
112 replies
RRailway
Created by justinw on 6/6/2023 in #✋|help
Infinite worker boot/crash loop
yeah
112 replies
RRailway
Created by justinw on 6/6/2023 in #✋|help
Infinite worker boot/crash loop
could be wrong but drawing blanks on our end after debugging for a bit
112 replies
RRailway
Created by justinw on 6/6/2023 in #✋|help
Infinite worker boot/crash loop
AFAIK we haven't changed any of our own settings - which is why im jumping into the discord. I think it's a platform thing
112 replies
RRailway
Created by justinw on 6/6/2023 in #✋|help
Infinite worker boot/crash loop
my bad - is there a way to escalate this on a diff channel?
112 replies
RRailway
Created by justinw on 6/6/2023 in #✋|help
Infinite worker boot/crash loop
lol
112 replies