diff options
| author | syeopite <syeopite@syeopite.dev> | 2025-02-26 14:04:29 -0800 |
|---|---|---|
| committer | syeopite <syeopite@syeopite.dev> | 2025-02-26 14:04:29 -0800 |
| commit | 3e329410d1f6426f49d0df425b31e78e9503bd9d (patch) | |
| tree | 3d363d2622b7647467a16441419f0b4e2b2a1f63 /src/invidious.cr | |
| parent | 74dfda150ed296acfdea0efe942a24d94fdab6a7 (diff) | |
| parent | b4a61936427545dd545c5581ea898f2d1c29d3ab (diff) | |
| download | invidious-3e329410d1f6426f49d0df425b31e78e9503bd9d.tar.gz invidious-3e329410d1f6426f49d0df425b31e78e9503bd9d.tar.bz2 invidious-3e329410d1f6426f49d0df425b31e78e9503bd9d.zip | |
Add the ability to listen on UNIX sockets (#5112)
Diffstat (limited to 'src/invidious.cr')
| -rw-r--r-- | src/invidious.cr | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index 566d4dc9..52df77be 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -240,8 +240,6 @@ add_context_storage_type(Preferences) add_context_storage_type(Invidious::User) Kemal.config.logger = LOGGER -Kemal.config.host_binding = Kemal.config.host_binding != "0.0.0.0" ? Kemal.config.host_binding : CONFIG.host_binding -Kemal.config.port = Kemal.config.port != 3000 ? Kemal.config.port : CONFIG.port Kemal.config.app_name = "Invidious" # Use in kemal's production mode. @@ -250,4 +248,16 @@ Kemal.config.app_name = "Invidious" Kemal.config.env = "production" if !ENV.has_key?("KEMAL_ENV") {% end %} -Kemal.run +Kemal.run do |config| + if socket_binding = CONFIG.socket_binding +File.delete?(socket_binding.path) + # Create a socket and set its desired permissions + server = UNIXServer.new(socket_binding.path) + perms = socket_binding.permissions.to_i(base: 8) + File.chmod(socket_binding.path, perms) + config.server.not_nil!.bind server + else + Kemal.config.host_binding = Kemal.config.host_binding != "0.0.0.0" ? Kemal.config.host_binding : CONFIG.host_binding + Kemal.config.port = Kemal.config.port != 3000 ? Kemal.config.port : CONFIG.port + end +end |
