public
Description: A very fast & simple Ruby web server
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/macournoyer/thin.git
Search Repo:
Move plateform check logic out of script.
macournoyer (author)
Thu Jan 17 19:55:04 -0800 2008
commit  bc601ce1a4f4e42e19b77d9574f7fdebae4b15e7
tree    41963326771eba4ab6aece11a238325d3c3810aa
parent  ca716970ee03dc0ed94bda0e4dc83b8a0bf0cb9d
...
73
74
75
76
77
78
79
80
81
82
...
73
74
75
 
 
 
 
76
77
78
0
@@ -73,10 +73,6 @@
0
     server.timeout = options[:timeout]
0
   
0
     if options[:daemonize]
0
- if RUBY_PLATFORM =~ /mswin/
0
- puts "Error: daemonizing not supported on Windows."
0
- exit 1
0
- end
0
       server.change_privilege options[:user], options[:group] if options[:user] && options[:group]
0
       server.daemonize
0
     end
...
31
32
33
 
34
35
36
...
49
50
51
 
52
53
54
55
...
92
93
94
 
 
 
 
95
96
97
98
 
99
100
101
...
31
32
33
34
35
36
37
...
50
51
52
53
54
55
56
57
...
94
95
96
97
98
99
100
101
102
103
 
104
105
106
107
0
@@ -31,6 +31,7 @@
0
     
0
     # Turns the current script into a daemon process that detaches from the console.
0
     def daemonize
0
+ check_plateform_support
0
       raise ArgumentError, 'You must specify a pid_file to deamonize' unless @pid_file
0
       
0
       pwd = Dir.pwd # Current directory is changed during daemonization, so store it
0
@@ -49,6 +50,7 @@
0
     # Change privileges of the process
0
     # to the specified user and group.
0
     def change_privilege(user, group=user)
0
+ check_plateform_support
0
       log ">> Changing process privilege to #{user}:#{group}"
0
       
0
       uid, gid = Process.euid, Process.egid
0
0
@@ -92,10 +94,14 @@
0
     end
0
     
0
     private
0
+ def check_plateform_support
0
+ raise RuntimeError, 'Daemonizing not supported on Windows' if RUBY_PLATFORM =~ /mswin/
0
+ end
0
+
0
       def remove_pid_file
0
         File.delete(@pid_file) if @pid_file && File.exists?(@pid_file)
0
       end
0
-
0
+
0
       def write_pid_file
0
         log ">> Writing PID to #{@pid_file}"
0
         FileUtils.mkdir_p File.dirname(@pid_file)

Comments

    No one has commented yet.