forked from zooniverse/cellect_panoptes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcellect_start
executable file
·54 lines (44 loc) · 1.09 KB
/
cellect_start
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env ruby
require_relative 'cellect_env'
require 'fileutils'
class CellectStart
include CellectEnv
def initialize
setup_new_relic_config
setup_env_vars
setup_puma_cmd
end
def run
if ENV['DEBUG_CELLECT_START']
p @env_vars
p @puma_cmd
end
exec(@env_vars, @puma_cmd)
end
private
def setup_puma_cmd
@puma_cmd = "puma -b tcp://0.0.0.0:#{puma_port} -t 0:#{puma_max_threads} -C config/puma.rb"
end
def puma_port
ENV['PUMA_PORT'] || 4000
end
def puma_max_threads
max_threads = ENV['PUMA_MAX_THREADS'] || @pg_pool
if max_threads.nil? || max_threads.to_s.empty?
16
else
max_threads
end
end
def setup_new_relic_config
source_path = '/production_config/newrelic.yml'
return unless File.exist?(source_path)
dest_path = '/cellect_panoptes/newrelic.yml'
dest_exists_as_file_or_link = File.exist?(dest_path) || File.symlink?(dest_path)
return if dest_exists_as_file_or_link
FileUtils.ln_sf(source_path, dest_path)
rescue Errno::ENOENT => e
p e.message
end
end
CellectStart.new.run