class Virtuaservices::Utils::Seeder
This class loads the necessary data in the database if they don't exist yet. @author Vincent Courtois <courtois.vincent@outlook.com>
Public Instance Methods
create_service(key)
click to toggle source
Creates the service if it does not exist, and the instance if it does not exist. @return [Virtuaservices::Monitoring::Service] the created, or found, service corresponding to this micro-service.
# File lib/virtuaservices/utils/seeder.rb, line 10 def create_service(key) service = Virtuaservices::Monitoring::Service.where(key: key).first if service.nil? service = Virtuaservices::Monitoring::Service.create!(key: key, path: "/#{key}", premium: true, active: true) end if service.instances.where(url: ENV['SERVICE_URL']).first.nil? Virtuaservices::Monitoring::Instance.create!(url: ENV['SERVICE_URL'], running: true, service: service, active: true) end return service end