Terminate current Rails instance from initializer -
i'm writing sanity-checking initializer should kill rails process in event properties not met. safest way abort production server's startup process in way? suppose extreme case running exit
, i'm not sure if it's best approach.
running on unicorn if matters.
there 3 ways end ruby process:
exit
end process status 0 (success).exit!
end status 1 (which seems appropriate case), , not run blocks defined usingkernel#at_exit
(which may or may not desirable you).abort
end status 1, , will runkernel#at_exit
blocks. can give string sent standard out.
so abort
best bet. unless have particular reason not run kernel#at_exit
blocks want run them.
since unicorn runs initializers once , forks processes after that, approach should fine.
i'll add i'm guessing doing these checks @ "wrong" level -- if possible should check health of environment outside of context of rails. don't know situation, , realize quickness of solution more valuable elegance. :)
Comments
Post a Comment