class Syncthing::Helper::CLI::UpdaterCommand

Public Instance Methods

api_key() click to toggle source
# File lib/syncthing/helper/cli/updater_command.rb, line 35
def api_key
  syncthing_api_key || Syncthing::Helper::API.api_key_from_xml(xml_config)
end
execute() click to toggle source
# File lib/syncthing/helper/cli/updater_command.rb, line 8
def execute
  super
  config_obj = API::Config.new
  config_obj.connect(syncthing_uri: syncthing_uri,
                     syncthing_api_key: api_key)

  %w(devices folders).each do |col_name|
    klass = ('Syncthing::Helper::API::' + col_name.capitalize + 'Updater').constantize
    instance_variable_set ('@' + col_name).to_sym, klass.new(config_obj: config_obj, col: col_name)
  end

  %w(term int quit).map(&:upcase).each do |sig|
    Signal.trap(sig) do
      Thread.new {shutdown}
      exit
    end
  end

  loop { sleep 60 }
end
shutdown() click to toggle source
# File lib/syncthing/helper/cli/updater_command.rb, line 29
def shutdown
  @devices.listener.stop
  @folders.listener.stop
  sleep 5
end