newbamboo / panda

Video encoding made easy with AWS

This URL has Read+Write access

panda / panda.god
100644 90 lines (81 sloc) 2.411 kb
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
God.watch do |w|
  w.name = "panda"
  current_path = "/var/local/www/panda"
  port = 4001
  w.start = "/bin/bash -c 'cd #{current_path}; merb -d -p #{port} -e production'"
  w.stop = "/bin/bash -c 'cd #{current_path}; merb -k #{port}'"
  w.pid_file = File.join(current_path, "log/merb.#{port}.pid")
  w.behavior(:clean_pid_file)
  w.start_grace = 10.seconds
  w.restart_grace = 10.seconds
  
  w.start_if do |start|
    start.condition(:process_running) do |c|
      c.interval = 10.seconds
      c.running = false
      c.notify = 'admin'
    end
  end
  
  w.restart_if do |restart|
    # Restart if not returning http success
    restart.condition(:http_response_code) do |c|
      c.interval = 5.seconds
      c.host = '127.0.0.1'
      c.port = port
      c.path = '/login'
      c.code_is_not = 200
      c.timeout = 10.seconds
      c.times = [2, 3] # 2 out of 3 intervals
    end
  end
end
 
God.watch do |w|
  w.name = "encoder"
  current_path = "/var/local/www/panda"
  port = 4091
  w.start = "/bin/bash -c 'cd #{current_path}; merb -r bin/encoder.rb -d -p #{port} -e encoder'"
  w.stop = "/bin/bash -c 'cd #{current_path}; merb -k #{port}'"
  w.pid_file = File.join(current_path, "log/merb.#{port}.pid")
  w.behavior(:clean_pid_file)
  w.start_grace = 10.seconds
  w.restart_grace = 10.seconds
  
  w.start_if do |start|
    start.condition(:process_running) do |c|
      c.interval = 10.seconds
      c.running = false
      c.notify = 'admin'
    end
  end
end
 
God.watch do |w|
  w.name = "notifier"
  current_path = "/var/local/www/panda"
  port = 6001
  w.start = "/bin/bash -c 'cd #{current_path}; merb -r bin/notifier.rb -d -p #{port} -e notifier'"
  w.stop = "/bin/bash -c 'cd #{current_path}; merb -k #{port}'"
  w.pid_file = File.join(current_path, "log/merb.#{port}.pid")
  w.behavior(:clean_pid_file)
  w.start_grace = 10.seconds
  w.restart_grace = 10.seconds
  
  w.start_if do |start|
    start.condition(:process_running) do |c|
      c.interval = 10.seconds
      c.running = false
      c.notify = 'admin'
    end
  end
end
 
God::Contacts::Email.message_settings = {
  :from => 'admin@localhost'
}
 
God::Contacts::Email.server_settings = {
  :address => "localhost",
  :port => 25,
  :domain => "pandastream.com"
  # :authentication => :plain,
  # :user_name => "john",
  # :password => "s3kr3ts"
}
 
God.contact(:email) do |c|
  c.name = 'admin'
  c.email = 'admin@localhost'
end