Skip to content

Commit

Permalink
feat: allow to disable "end on process signal" handlers
Browse files Browse the repository at this point in the history
Implements #280
  • Loading branch information
Cactusbone committed Oct 11, 2024
1 parent 89bd13d commit 8c48fe0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ A [bunyan logger](https://github.com/trentm/node-bunyan) instance. Created by de
Sets the timeout (in ms) after that an idle connection is closed by the server
__Default:__ `0`

#### `endOnProcessSignal`
Whether to close ftp server and exit process on SIGTERM/SIGINT/SIGQUIT signals or not
__Default:__ `true`

## CLI

`ftp-srv` also comes with a builtin CLI.
Expand Down
11 changes: 7 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class FtpServer extends EventEmitter {
whitelist: [],
greeting: null,
tls: false,
timeout: 0
timeout: 0,
endOnProcessSignal: true,
}, options);

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

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

process.on('SIGTERM', quit);
process.on('SIGINT', quit);
process.on('SIGQUIT', quit);
if (this.options.endOnProcessSignal) {
process.on('SIGTERM', quit);
process.on('SIGINT', quit);
process.on('SIGQUIT', quit);
}
}

get isTLS() {
Expand Down

0 comments on commit 8c48fe0

Please sign in to comment.