Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show chords progress #12

Merged
merged 3 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
209 changes: 196 additions & 13 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"cors": "^2.8.5",
"easymidi": "^3.0.1",
"express": "^4.18.2",
"node-global-key-listener": "^0.1.1"
"node-global-key-listener": "^0.1.1",
"socket.io": "^4.6.1"
},
"devDependencies": {
"@types/cors": "^2.8.13",
Expand Down
29 changes: 29 additions & 0 deletions server/src/exit_handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import process from 'node:process';

import type App from '@shared/app';

export const exitHandler = (app: App) => {
// so the program will not close instantly
app.deps.stdin.resume();

const handle = (options, exitCode) => {
if (options.cleanup) {
app.close();
}
if (options.exit) {
process.exit();
}
}

// always runs after other handlers
process.on('exit', handle.bind(null, {cleanup: true}));

// catches ctrl+c event
process.on('SIGINT', handle.bind(null, {exit: true}));

// catches "kill pid" (for example: nodemon restart)
process.on('SIGUSR1', handle.bind(null, {exit: true}));
process.on('SIGUSR2', handle.bind(null, {exit: true}));

// process.on('uncaughtException', handle.bind(null, {exit: true}));
}
Loading