Skip to content

Commit

Permalink
Merge pull request #135 from GeneralMagicio/feat/run-migrations-job-mode
Browse files Browse the repository at this point in the history
Run migrations only by the job server
  • Loading branch information
aminlatifi authored Nov 4, 2024
2 parents 6c72097 + d3c104d commit ea2356c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,7 @@ class Config {

const config = new Config(process.env);

export const isGraphQlMode = config.get('GRAPHQL_MODE') === 'true';
export const isJobMode = config.get('JOB_MODE') === 'true';

export default config;
3 changes: 2 additions & 1 deletion src/orm.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DataSource } from 'typeorm';
import { PostgresConnectionCredentialsOptions } from 'typeorm/driver/postgres/PostgresConnectionCredentialsOptions';
import config from './config';
import config, { isJobMode } from './config';
import { CronJob } from './entities/CronJob';
import { getEntities } from './entities/entities';
import { redisConfig } from './redis';
Expand Down Expand Up @@ -57,6 +57,7 @@ export class AppDataSource {
},
},
poolSize,
migrationsRun: isJobMode,
extra: {
maxWaitingClients: 10,
evictionRunIntervalMillis: 500,
Expand Down
5 changes: 1 addition & 4 deletions src/server/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import bodyParser from 'body-parser';
import graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.js';
import { ApolloServerPluginLandingPageDisabled } from '@apollo/server/plugin/disabled';
import { ApolloServerErrorCode } from '@apollo/server/errors';
import config from '../config';
import config, { isGraphQlMode, isJobMode } from '../config';
import { handleStripeWebhook } from '../utils/stripe';
import createSchema from './createSchema';
import SentryLogger from '../sentryLogger';
Expand Down Expand Up @@ -83,9 +83,6 @@ export async function bootstrap() {
try {
logger.debug('bootstrap() has been called', new Date());

const isGraphQlMode = config.get('GRAPHQL_MODE') === 'true';
const isJobMode = config.get('JOB_MODE') === 'true';

logger.info('isGraphQlMode: ', isGraphQlMode);
logger.info('isJobMode: ', isJobMode);

Expand Down

0 comments on commit ea2356c

Please sign in to comment.