Skip to content

Commit

Permalink
Fix: prax crashes when demonized
Browse files Browse the repository at this point in the history
Crystal 0.8.0 changed the signature or IO reopen.
  • Loading branch information
ysbaddaden committed Sep 29, 2015
1 parent 9a26118 commit f0b1519
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/prax.cr
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,22 @@ lib LibC
fun setsid() : PidT
end

class IO::FileDescriptor
def reopen(path : String, mode = "r")
reopen(File.open(path, mode))
end
end

if Prax.daemonize
exit if fork
LibC.setsid

exit if fork
Dir.chdir "/"

File.open("/dev/null").reopen(STDIN)
File.open(File.join(Prax.logs_path, "prax.log"), "w").reopen(STDOUT)
File.open(File.join(Prax.logs_path, "prax.log"), "w").reopen(STDERR)
STDIN.reopen("/dev/null")
STDOUT.reopen(File.join(Prax.logs_path, "prax.log"), "w")
STDERR.reopen(File.join(Prax.logs_path, "prax.log"), "w")

Prax.start
end
Expand Down

0 comments on commit f0b1519

Please sign in to comment.