Skip to content

Commit 8c48fe0

Browse files
committed
feat: allow to disable "end on process signal" handlers
Implements #280
1 parent 89bd13d commit 8c48fe0

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ A [bunyan logger](https://github.com/trentm/node-bunyan) instance. Created by de
161161
Sets the timeout (in ms) after that an idle connection is closed by the server
162162
__Default:__ `0`
163163

164+
#### `endOnProcessSignal`
165+
Whether to close ftp server and exit process on SIGTERM/SIGINT/SIGQUIT signals or not
166+
__Default:__ `true`
167+
164168
## CLI
165169

166170
`ftp-srv` also comes with a builtin CLI.

src/index.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class FtpServer extends EventEmitter {
2424
whitelist: [],
2525
greeting: null,
2626
tls: false,
27-
timeout: 0
27+
timeout: 0,
28+
endOnProcessSignal: true,
2829
}, options);
2930

3031
this._greeting = this.setupGreeting(this.options.greeting);
@@ -70,9 +71,11 @@ class FtpServer extends EventEmitter {
7071

7172
const quit = _.debounce(this.quit.bind(this), 100);
7273

73-
process.on('SIGTERM', quit);
74-
process.on('SIGINT', quit);
75-
process.on('SIGQUIT', quit);
74+
if (this.options.endOnProcessSignal) {
75+
process.on('SIGTERM', quit);
76+
process.on('SIGINT', quit);
77+
process.on('SIGQUIT', quit);
78+
}
7679
}
7780

7881
get isTLS() {

0 commit comments

Comments
 (0)