app: exit gracefully when a main script throws an error
Code to run main script (passed via command line args, or interactive console) has a footer where it notifies systemd, logs a happened error, and panics. Before the patch that code was unreachable in case of any exception in a main script, because panic happened earlier. Now a happened exception is correctly carried to the footer with proper error processing. A first and obvious solution was replace all panics with diag_set and use fiber_join on the script runner fiber. But appeared, that the fiber running a main script can't be joined. This is because normally it exits via os.exit() which never returns and therefore its caller never dies = can't be joined. The patch solves this problem by passing main fiber diag to the script runner by pointer, eliminating fiber_join necessity. Closes #4382
Showing
- src/lua/init.c 39 additions, 25 deletionssrc/lua/init.c
- src/lua/init.h 5 additions, 1 deletionsrc/lua/init.h
- src/main.cc 3 additions, 2 deletionssrc/main.cc
- test/app-tap/fail_main.result 3 additions, 0 deletionstest/app-tap/fail_main.result
- test/app-tap/fail_main.test.lua 39 additions, 0 deletionstest/app-tap/fail_main.test.lua
Loading
Please register or sign in to comment