diff --git a/Gemfile b/Gemfile index f10e5297..8d539d5b 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ gem 'sequel' gem 'slim' gem 'bcrypt-ruby', require: 'bcrypt' gem 'sinatra-flash', require: 'sinatra/flash' +gem 'sinatra-xsendfile', require: 'sinatra/xsendfile' gem 'puma', require: nil platform :mri do diff --git a/Gemfile.lock b/Gemfile.lock index b1714a9d..19b3fc06 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -64,6 +64,8 @@ GEM tilt (~> 1.3, >= 1.3.4) sinatra-flash (0.3.0) sinatra (>= 1.0.0) + sinatra-xsendfile (0.4.0) + sinatra (>= 0.9.1) slim (1.3.9) temple (~> 0.6.3) tilt (~> 1.3, >= 1.3.3) @@ -101,5 +103,6 @@ DEPENDENCIES simplecov sinatra sinatra-flash + sinatra-xsendfile slim webmock diff --git a/rainbows_config.rb b/rainbows_config.rb new file mode 100644 index 00000000..d9d5c09a --- /dev/null +++ b/rainbows_config.rb @@ -0,0 +1,30 @@ +Rainbows! do + name = 'neocities' + + use :ThreadPool + + client_max_body_size 1*1024*1024 # 1 Megabyte + + worker_processes 8 + worker_connections 32 + timeout 10 + + listen "unix:tmp/#{name}.sock", :backlog => 2048 + + pid "tmp/#{name}.pid" + stderr_path "tmp/#{name}.log" + stdout_path "tmp/#{name}.log" + + preload_app true + + before_fork do |server, worker| + old_pid = "tmp/#{name}.pid.oldbin" + if File.exists?(old_pid) && server.pid != old_pid + begin + Process.kill("QUIT", File.read(old_pid).to_i) + rescue Errno::ENOENT, Errno::ESRCH + # someone else did our job for us + end + end + end +end \ No newline at end of file