From b3e84e27f895a8ae21142f3a78b1c42f57888a0a Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Mon, 9 Apr 2018 22:07:09 -0500 Subject: [PATCH] Allow channel_threads to be configured and increase pool_size --- config/config.yml | 3 ++- src/helpers.cr | 7 ++++--- src/invidious.cr | 10 +++++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/config/config.yml b/config/config.yml index f8a06faa..0dc93f86 100644 --- a/config/config.yml +++ b/config/config.yml @@ -1,4 +1,5 @@ -pool_size: 10 +pool_size: 20 +channel_threads: 5 threads: 5 db: user: kemal diff --git a/src/helpers.cr b/src/helpers.cr index 4fe8ae4f..4b5a77e0 100644 --- a/src/helpers.cr +++ b/src/helpers.cr @@ -15,9 +15,10 @@ end class Config YAML.mapping({ - pool_size: Int32, - threads: Int32, - db: NamedTuple( + pool_size: Int32, + threads: Int32, + channel_threads: Int32, + db: NamedTuple( user: String, password: String, host: String, diff --git a/src/invidious.cr b/src/invidious.cr index 5437c356..37ee19c6 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -27,7 +27,7 @@ CONFIG = Config.from_yaml(File.read("config/config.yml")) pool_size = CONFIG.pool_size threads = CONFIG.threads -channel_threads = 10 +channel_threads = CONFIG.channel_threads Kemal.config.extra_options do |parser| parser.banner = "Usage: invidious [arguments]" @@ -47,6 +47,14 @@ Kemal.config.extra_options do |parser| exit end end + parser.on("-c THREADS", "--channel-threads=THREADS", "Number of threads for refreshing channels (default: #{channel_threads})") do |number| + begin + channel_threads = number.to_i + rescue ex + puts "THREADS must be integer" + exit + end + end end Kemal::CLI.new