Class: RightScale::OptionsBag
Overview
Store agent options in environment variable so child processes can access them too
Constant Summary collapse
- OPTIONS_ENV =
(String) Name of environment variable containing serialized options hash
'RS_OPTIONS'
Class Method Summary collapse
-
.load ⇒ Object
Load previously stored options (may have been stored in a parent process).
-
.store(opts) ⇒ Object
Store options.
Class Method Details
.load ⇒ Object
Load previously stored options (may have been stored in a parent process)
Return
- opts(Hash)
-
Previously stored options, empty hash if there is none
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/instance/options_bag.rb', line 50 def self.load return {} unless serialized = ENV[OPTIONS_ENV] begin opts = JSON.load(serialized) opts = SerializationHelper.symbolize_keys(opts) rescue Exception => e Log.warning("Failed to deserialize options", e) opts = {} end opts end |
.store(opts) ⇒ Object
Store options
Parameters
- opts(Hash)
-
Options to be stored, override any options stored earlier
Result
- opts(Hash)
-
Options to be stored
41 42 43 44 |
# File 'lib/instance/options_bag.rb', line 41 def self.store(opts) ENV[OPTIONS_ENV] = JSON.dump(opts) opts end |