aboutsummaryrefslogtreecommitdiffstats
path: root/sdc-os-chef/sdc-backend/chef-repo/cookbooks/sdc-normatives/recipes/check_Backend.rb
blob: 00bb50ebd83fc44fc9b09177e0d62e87c3d87e90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
ruby_block "check_Backend_Health" do
    block do
      printf("\033[32m%s\n\033[0m", "  executing BackEnd health-check, please wait...")
      Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut)
      curl_command = "http://localhost:8080/sdc2/rest/v1/user/jh0003"
      resp = Net::HTTP.get_response URI.parse(curl_command)
      stat = resp.code

      case stat
         when '200'
            printf("\033[32m%s\n\033[0m", "  BackEnd is up.")
         else
            printf("\033[31mstat=[%s]\n\033[0m", stat)
            printf("\033[31m%s\n\033[0m", "  BackEnd is DOWN!!!")
      end
   end
   retries 12
   retry_delay 5
end