process - Erlang alternative to trap_exit? -
I would like to execute some code when my Gn_ server stops, I have my gen_server trapping exhaust (I in init callback process_flag (trap_exit, true) added). This process works well because
ends / 2 always gets out of the process. I know that since I work to trap the process related to the exit, the crash which does not crash my gene_surver. I can work around this, but I am thinking that there is no alternative to using the
process_flag (trap_exit, true) to achieve this goal?
I just need a "callback before going out of the process" Is there something like this exit?
@ Pascal's answer is absolutely correct, but I'm another Aproach.
Sometimes you want to lay down the processes by gen_server , but generally, you can put them in the supervision hierarchy, which is more secure. You may have created those processes and the gen_server with the same supervisor with the one_fure_l restart strategy If one of the procedures dies, they all resume. Second, you have to specify timeout for the shutdown strategy - will ensure that the ending function will be called.
Comments
Post a Comment