Class: Specjour::RsyncDaemon
- Inherits:
-
Object
- Object
- Specjour::RsyncDaemon
show all
- Includes:
- SocketHelpers
- Defined in:
- lib/specjour/rsync_daemon.rb
Constant Summary
collapse
- CONFIG_VERSION =
Corresponds to the version of specjour that changed the configuration file.
"0.2.3".freeze
- CONFIG_FILE_NAME =
"rsyncd.conf"
- PID_FILE_NAME =
"rsyncd.pid"
Instance Attribute Summary collapse
Instance Method Summary
collapse
#hostname, #ip_from_hostname
Constructor Details
#initialize(project_path, project_name) ⇒ RsyncDaemon
Returns a new instance of RsyncDaemon.
14
15
16
17
|
# File 'lib/specjour/rsync_daemon.rb', line 14
def initialize(project_path, project_name)
@project_path = project_path
@project_name = project_name
end
|
Instance Attribute Details
#project_name ⇒ Object
Returns the value of attribute project_name.
12
13
14
|
# File 'lib/specjour/rsync_daemon.rb', line 12
def project_name
@project_name
end
|
#project_path ⇒ Object
Returns the value of attribute project_path.
12
13
14
|
# File 'lib/specjour/rsync_daemon.rb', line 12
def project_path
@project_path
end
|
Instance Method Details
#config_directory ⇒ Object
19
20
21
|
# File 'lib/specjour/rsync_daemon.rb', line 19
def config_directory
@config_directory ||= File.join(project_path, ".specjour")
end
|
#config_file ⇒ Object
23
24
25
|
# File 'lib/specjour/rsync_daemon.rb', line 23
def config_file
@config_file ||= File.join(config_directory, CONFIG_FILE_NAME)
end
|
#pid ⇒ Object
27
28
29
30
31
|
# File 'lib/specjour/rsync_daemon.rb', line 27
def pid
if File.exists?(pid_file)
File.read(pid_file).strip.to_i
end
end
|
#pid_file ⇒ Object
33
34
35
|
# File 'lib/specjour/rsync_daemon.rb', line 33
def pid_file
File.join(config_directory, PID_FILE_NAME)
end
|
#start ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/specjour/rsync_daemon.rb', line 37
def start
write_config
Dir.chdir(project_path) do
Kernel.system *command
end
Kernel.at_exit { stop }
end
|
#stop ⇒ Object
45
46
47
48
49
50
|
# File 'lib/specjour/rsync_daemon.rb', line 45
def stop
if pid
Process.kill("TERM", pid)
FileUtils.rm(pid_file)
end
end
|