-
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
88 additions
and
36 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { fatal, info } from './utils/logger' | ||
import client from './structures/client' | ||
import * as Sentry from '@sentry/node' | ||
import { RewriteFrames } from '@sentry/integrations' | ||
import { promisify } from 'util' | ||
import { exec } from 'child_process' | ||
import dirImport from './utils/dir-import' | ||
|
||
info('Starting up...', 'Preflight'); | ||
|
||
(async () => { | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const revision = (await promisify(exec)('git rev-parse HEAD').catch(() => { return { stdout: require('../package.json').version } })).stdout.toString().trim() | ||
info(`Initialzing Sentry, using revision ${revision as string}`, 'Preflight') | ||
Sentry.init({ | ||
dsn: process.env.SENTRY_DSN, | ||
integrations: function (integrations) { | ||
return integrations | ||
.concat(new RewriteFrames({ root: __dirname ?? process.cwd() })) | ||
.filter(function (integration) { | ||
return integration.name !== 'Console' | ||
}) | ||
}, | ||
release: revision | ||
}) | ||
await dirImport('@(dist|src)/languages/**/*.[?jt]s') | ||
await dirImport('@(dist|src)/events/**/*.[?jt]s') | ||
await client.addMultipleIn('./interactions') | ||
await client.run() | ||
await dirImport('@(dist|src)/jobs/**/*.client.[?jt]s') | ||
await client.checkAndUploadCommands() | ||
})().catch(e => fatal(e, 'Startup')) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,18 @@ | ||
import { fatal, info } from './utils/logger' | ||
import client from './structures/client' | ||
import * as Sentry from '@sentry/node' | ||
import { RewriteFrames } from '@sentry/integrations' | ||
import { promisify } from 'util' | ||
import { exec } from 'child_process' | ||
import cluster from './structures/cluster' | ||
import dirImport from './utils/dir-import' | ||
import { fatal, info, warn } from './utils/logger' | ||
|
||
info('Starting up...', 'Preflight'); | ||
cluster.on('clusterProcess', (payload) => { | ||
payload.clusterProcess.on('ready', () => { | ||
info('Cluster has reported ready', `Cluster ${payload.clusterProcess.clusterId}`) | ||
}) | ||
payload.clusterProcess.on('warn', ctx => { | ||
warn(ctx.error, `Cluster ${payload.clusterProcess.clusterId}`) | ||
}) | ||
}); | ||
|
||
(async () => { | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const revision = (await promisify(exec)('git rev-parse HEAD').catch(() => { return { stdout: require('../package.json').version } })).stdout.toString().trim() | ||
info(`Initialzing Sentry, using revision ${revision as string}`, 'Preflight') | ||
Sentry.init({ | ||
dsn: process.env.SENTRY_DSN, | ||
integrations: function (integrations) { | ||
return integrations | ||
.concat(new RewriteFrames({ root: __dirname ?? process.cwd() })) | ||
.filter(function (integration) { | ||
return integration.name !== 'Console' | ||
}) | ||
}, | ||
release: revision | ||
}) | ||
await dirImport('@(dist|src)/languages/**/*.[?jt]s') | ||
await dirImport('@(dist|src)/events/**/*.[?jt]s') | ||
await client.addMultipleIn('./interactions') | ||
await client.run() | ||
await client.checkAndUploadCommands() | ||
})().catch(e => fatal(e, 'Startup')) | ||
await cluster.run() | ||
info(`Now running ${cluster.clusterCount} clusters with ${cluster.shardsPerCluster} shards on each one`, 'Clustering') | ||
await dirImport('@(dist|src)/jobs/**/*.cluster.[?jt]s') | ||
})().catch(e => fatal(e, 'Clustering')) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { ClusterManager } from 'detritus-client' | ||
|
||
const IS_TS_NODE = Symbol.for('ts-node.register.instance') in process | ||
|
||
// the filename is NOT relative to this file | ||
// but to where the file is being run first | ||
// which in this case is the index.ts file | ||
const manager = new ClusterManager(IS_TS_NODE ? './entry.ts' : './entry.js', process.env.BOT_TOKEN ?? '') | ||
|
||
export default manager |