Class: Specjour::RsyncDaemon

Inherits:
Object
  • Object
show all
Defined in:
lib/specjour/rsync_daemon.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_path, project_name) ⇒ RsyncDaemon

Returns a new instance of RsyncDaemon.



6
7
8
9
# File 'lib/specjour/rsync_daemon.rb', line 6

def initialize(project_path, project_name)
  @project_path = project_path
  @project_name = project_name
end

Instance Attribute Details

#project_nameObject (readonly)

Returns the value of attribute project_name.



5
6
7
# File 'lib/specjour/rsync_daemon.rb', line 5

def project_name
  @project_name
end

#project_pathObject (readonly)

Returns the value of attribute project_path.



5
6
7
# File 'lib/specjour/rsync_daemon.rb', line 5

def project_path
  @project_path
end

Instance Method Details

#config_fileObject



11
12
13
# File 'lib/specjour/rsync_daemon.rb', line 11

def config_file
  File.join("/tmp", "rsyncd.conf")
end

#startObject



15
16
17
18
19
# File 'lib/specjour/rsync_daemon.rb', line 15

def start
  write_config
  system("rsync", "--daemon", "--config=#{config_file}", "--port=8989")
  at_exit { puts 'shutting down rsync'; stop }
end

#stopObject



21
22
23
24
25
26
# File 'lib/specjour/rsync_daemon.rb', line 21

def stop
  if pid
    Process.kill("TERM", pid)
    FileUtils.rm(pid_file)
  end
end