class WatchCommand

Public Instance Methods

execute() click to toggle source
# File lib/sinatra_live.rb, line 30
def execute
  # read Livefile
  livefile = load_livefile
  # start watching folders
  log "Watching folders for changes"
  livefile['folders'].each do |folder|
    log "\t#{folder}"
  end
  puts

  FileWatcher.new(livefile['folders']).watch do |filename|
    log "Updated " + filename
    # call control url to reload on changes
    puma_control_url = livefile['puma']['control'] + "/restart?token=" + livefile['puma']['token']

    result = Net::HTTP.get(URI.parse(puma_control_url))
    log "\tserver restart"
  end

end