Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitaly-ruby « bin « ruby - gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 395d6b4f60b1c959321344e76b42a24f13774e0a (plain)
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
55
56
57
58
59
60
#!/usr/bin/env ruby

puts "gitaly-ruby BUNDLE_GEMFILE #{ENV['BUNDLE_GEMFILE']}"

require 'fileutils'
require 'logger'

$logger = Logger.new(STDOUT)
$logger.progname = 'gitaly-ruby'
$logger.level = :warn

module GRPC
  def self.logger
    $logger
  end
end

require 'grpc'
require 'rugged'

require_relative '../lib/gitaly_server.rb'

def main
  if ARGV.length != 1
    abort "Usage: #{$0} /path/to/socket"
  end

  start_parent_watcher

  socket_path = ARGV.first
  FileUtils.rm_f(socket_path)
  socket_dir = File.dirname(socket_path)
  FileUtils.mkdir_p(socket_dir)
  File.chmod(0700, socket_dir)

  s = GRPC::RpcServer.new
  port = 'unix:' + socket_path
  s.add_http2_port(port, :this_port_is_insecure)
  $logger.warn "running insecurely on #{port}"
  $logger.warn "using rugged #{Rugged::VERSION}"

  GitalyServer.register_handlers(s)

  s.run_till_terminated
end

def start_parent_watcher
  Thread.new do
    loop do
      if Process.ppid == 1
        # If our parent is PID 1, our original parent is gone. Self-terminate.
        Process.kill(9, Process.pid)
      end

      sleep 1
    end
  end
end

main