eye.rb 2.14 KB
Newer Older
1 2
# frozen_string_literal: true

Jonne Haß's avatar
Jonne Haß committed
3 4 5 6 7 8 9 10 11
require_relative "load_config"
rails_env = ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"

Eye.config do
  logger Logger.new(STDOUT)
end

Eye.application("diaspora") do
  working_dir Rails.root.to_s
12
  env "RAILS_ENV" => rails_env
13 14
  stdout "log/eye_processes_stdout.log" unless rails_env == "development"
  stderr "log/eye_processes_stderr.log"
Jonne Haß's avatar
Jonne Haß committed
15 16

  process :web do
17 18 19 20 21 22 23 24 25 26 27 28 29
    unicorn_command = "bin/bundle exec unicorn -c config/unicorn.rb"

    if rails_env == "production"
      start_command "#{unicorn_command} -D"
      daemonize false
      restart_command "kill -USR2 {PID}"
      restart_grace 10.seconds
    else
      start_command unicorn_command
      daemonize true
    end

    pid_file AppConfig.server.pid.get
Jonne Haß's avatar
Jonne Haß committed
30
    stop_signals [:TERM, 10.seconds]
31

Jonne Haß's avatar
Jonne Haß committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
    env "PORT" => ENV["PORT"]

    monitor_children do
      stop_command "kill -QUIT {PID}"
    end
  end

  group :sidekiq do
    with_condition(!AppConfig.environment.single_process_mode?) do
      AppConfig.server.sidekiq_workers.to_i.times do |i|
        i += 1

        process "sidekiq#{i}" do
          start_command "bin/bundle exec sidekiq"
          daemonize true
          pid_file "tmp/pids/sidekiq#{i}.pid"
          stop_signals [:USR1, 0, :TERM, 10.seconds, :KILL]
        end
      end
    end
  end

David Morley's avatar
David Morley committed
54 55 56 57
    with_condition(!AppConfig.environment.single_process_mode?) do
        process :camo do
          start_command "nodejs /home/david/camo/server.js"
          daemonize true
58 59 60 61 62 63
          env "PORT" => 8081
          env "CAMO_KEY" => AppConfig.privacy.camo.key.get
          env "NODE_TLS_REJECT_UNAUTHORIZED" => 0
          env "CAMO_LENGTH_LIMIT" => 39485760
          env "CAMO_HEADER_VIA" => "Camo Asset Proxy from diasp.org"
          env "CAMO_HOSTNAME" => "diasp.org"
David Morley's avatar
David Morley committed
64 65 66 67 68
          pid_file "tmp/pids/camo.pid"
          stop_signals [:USR1, 0, :TERM, 10.seconds, :KILL]
        end
    end

Jonne Haß's avatar
Jonne Haß committed
69 70
  with_condition(AppConfig.chat.enabled? && AppConfig.chat.server.enabled?) do
    process :xmpp do
71
      start_command "bin/bundle exec rails runner Prosody.start"
Jonne Haß's avatar
Jonne Haß committed
72
      daemonize true
David Morley's avatar
David Morley committed
73
      pid_file "/tmp/xmpp.pid"
David Morley's avatar
t  
David Morley committed
74
      stop_signals [:TERM, 20.seconds, :KILL]
Jonne Haß's avatar
Jonne Haß committed
75 76 77
    end
  end
end
78