Skip to content

Instantly share code, notes, and snippets.

@evantahler
Last active February 9, 2020 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evantahler/3e65a20627d781e7fb03cce71566218a to your computer and use it in GitHub Desktop.
Save evantahler/3e65a20627d781e7fb03cce71566218a to your computer and use it in GitHub Desktop.
Actionhero#future
// 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