Module: LapisLazuli::WorldModule::Proxy
Overview
Module managing a proxy instance
Instance Method Summary collapse
-
#has_proxy? ⇒ Boolean
Checks if there is a proxy started.
-
#proxy ⇒ Object
Get the current proxy.
Methods included from Logging
Methods included from Config
#config, #current_env, #env, #env_or_config, #has_config?, #has_env?, #has_env_or_config?, #init, #load_config, #load_config_from_file, #var_from_env
Methods included from Config::ClassMethods
Instance Method Details
#has_proxy? ⇒ Boolean
Checks if there is a proxy started
25 26 27 28 |
# File 'lib/lapis_lazuli/world/proxy.rb', line 25 def has_proxy? proxy = Runtime.instance.get :proxy return !proxy.nil? end |
#proxy ⇒ Object
Get the current proxy
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 |
# File 'lib/lapis_lazuli/world/proxy.rb', line 32 def proxy return Runtime.instance.set_if(self, :proxy) do # Check if we can start a proxy begin # Default proxy settings proxy_ip = "localhost" proxy_port = 10000 proxy_master = true # Do we have a config? if has_env_or_config?("proxy.ip") and has_env_or_config?("proxy.port") proxy_ip = env_or_config("proxy.ip") proxy_port = env_or_config("proxy.port") proxy_master = env_or_config("proxy.spritecloud", true) end # Try to start the proxy proxy = LapisLazuli::Proxy.new(proxy_ip, proxy_port, proxy_master) log.debug("Found proxy: #{proxy_ip}:#{proxy_port}, spritecloud: #{proxy_master}") rescue StandardError => err log.debug("No proxy available: #{err}") end end end |