| 117 | } |
| 118 | |
| 119 | function next (err) { |
| 120 | if (err) { |
| 121 | exit(err) |
| 122 | return |
| 123 | } |
| 124 | |
| 125 | if (i === hooks.length && c === server[kChildren].length) { |
| 126 | if (i === 0 && c === 0) { // speed up start |
| 127 | exit() |
| 128 | } else { |
| 129 | // This is the last function executed for every fastify instance |
| 130 | boot(function manageTimeout (err, done) { |
| 131 | // this callback is needed by fastify to provide an hook interface without the error |
| 132 | // as first parameter and managing it on behalf the user |
| 133 | exit(err) |
| 134 | |
| 135 | // this callback is needed by avvio to continue the loading of the next `register` plugins |
| 136 | done(err) |
| 137 | }) |
| 138 | } |
| 139 | return |
| 140 | } |
| 141 | |
| 142 | if (i === hooks.length && c < server[kChildren].length) { |
| 143 | const child = server[kChildren][c++] |
| 144 | hookRunnerApplication(hookName, boot, child, next) |
| 145 | return |
| 146 | } |
| 147 | |
| 148 | boot(wrap(hooks[i++], server)) |
| 149 | next() |
| 150 | } |
| 151 | |
| 152 | function wrap (fn, server) { |
| 153 | return function (err, done) { |