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:
exitend 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).abortend status 1, , will runkernel#at_exitblocks. 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