rails s -p 16052 -d
ruby script/server -p 16050 -d
啟動(dòng)守護(hù)進(jìn)程后,當(dāng)前路徑變?yōu)?根路徑/ 忍啤,所有相對(duì)路徑的寫(xiě)法就會(huì)有問(wèn)題(Dir.pwd變?yōu)?/)
在 puma.rb里 設(shè)置 daemonize true 加勤,當(dāng)前路徑還是 項(xiàng)目路徑
The Puma 5.0 release removed daemonization. For older versions and alternatives, continue reading.
https://blog.csdn.net/xingchao_1995/article/details/60151552
puts 'parent'
puts "pid:#{Process.pid}"
exit if fork
puts "fork1,pid:#{Process.pid}"
Process.setsid
puts "setsid,pid:#{Process.pid}"
exit if fork
puts "fork2,pid:#{Process.pid}"
puts "now_dir:#{Dir.pwd}"
Process.daemon
File.open("/Users/rcc/Desktop/process.txt",'wb'){|f| f.puts("pid:#{Process.pid}")}
File.open("/Users/rcc/Desktop/process.txt",'a+'){|f| f.puts(Dir.pwd)}
while true
File.open("/Users/rcc/Desktop/process.txt",'a+'){|f| f.puts(Time.now.to_i)}
sleep(1)
end