Class: Vagrant::Syncer::Actions::StartSyncer

Inherits:
Object
  • Object
show all
Defined in:
lib/syncer/actions.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ StartSyncer

Returns a new instance of StartSyncer.



6
7
8
9
# File 'lib/syncer/actions.rb', line 6

def initialize(app, env)
  @app = app
  @exit_registered = false
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/syncer/actions.rb', line 11

def call(env)
  @app.call(env)

  return  unless env[:machine].config.syncer.run_on_startup
  return  if @exit_registered

  at_exit do
    exit 1  unless $!.is_a?(SystemExit)
    exit_status = $!.status
    exit exit_status  if exit_status != 0

    # If vagrant up/reload/resume exited successfully, run rsync-auto.
    env[:machine].env.cli("rsync-auto")
  end

  @exit_registered = true
end