Last active
February 9, 2020 03:39
-
-
Save evantahler/3e65a20627d781e7fb03cce71566218a to your computer and use it in GitHub Desktop.
Actionhero#future
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// There is no more actionhero CLI (start, startCluster, etc). You make your own 'main' file. | |
// This should make running in Docker, Serverless, etc easier. | |
// This also removes `boot.js` | |
import { Process, config, log } from '@actionhero/core' // we use NPM namespaces | |
// The core Actionhero package is really small... and you can opt-in to the parts you want | |
import WebServer from '@actionhero/web' | |
import WebSocketServer from '@actionhero/websocket' | |
import Cache from '@actionhero/cache' | |
import Resque from '@actionhero/resque' | |
async function main () { | |
// Paths are no loger assumed, and are set directly | |
// Our config system is likely too complex, and should be simplified (or left up to the developer to tweak) | |
await config.setPath('./config') | |
// opt-into the plugins you need directly, removes `config/plugins` | |
const app = new Process( | |
WebServer, WebSocketServer, Cache, Resque | |
) | |
// handle errors & rejections | |
process.on("uncaughtException", (error: Error) => { | |
log(error.stack, "fatal"); | |
process.nextTick(process.exit); | |
}); | |
process.on("unhandledRejection", (rejection: Error) => { | |
log(rejection.stack, "fatal"); | |
process.nextTick(process.exit); | |
}); | |
// handle signals | |
process.on("SIGINT", async () => { | |
await app.stop(); | |
}); | |
process.on("SIGTERM", async () => { | |
await app.stop(); | |
}); | |
process.on("SIGUSR2", async () => { | |
await app.restart(); | |
}); | |
await app.start(); | |
} | |
main () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment