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

feat(server): add server timeout configuration #623 #741

Merged
merged 5 commits into from
Jul 20, 2018
Merged
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
6 changes: 6 additions & 0 deletions src/postgraphile/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ program
.option('-b, --disable-graphiql', 'disables the GraphiQL interface. overrides the GraphiQL route option')
.option('-o, --cors', 'enable generous CORS settings; disabled by default, if possible use a proxy instead')
.option('-l, --body-size-limit <string>', 'set the maximum size of JSON bodies that can be parsed (default 100kB) The size can be given as a human-readable string, such as \'200kB\' or \'5MB\' (case insensitive).')
.option('--timeout <number>', 'set the timeout value in milliseconds for sockets', parseFloat)
.option('--cluster-workers <count>', '[experimental] spawn <count> workers to increase throughput', parseFloat)
.option('--enable-query-batching', '[experimental] enable the server to process multiple GraphQL queries in one request')
.option('--disable-query-log', 'disable logging queries to console (recommended in production)')
Expand Down Expand Up @@ -197,6 +198,7 @@ const {
schema: dbSchema,
host: hostname = 'localhost',
port = 5000,
timeout: serverTimeout,
maxPoolSize,
defaultRole: pgDefaultRole,
graphql: graphqlRoute = '/graphql',
Expand Down Expand Up @@ -448,6 +450,10 @@ if (noServer) {
const rawMiddleware = postgraphile(pgConfig, schemas, postgraphileOptions)
const middleware = pluginHook('cli:server:middleware', rawMiddleware, { options: postgraphileOptions })
const server = createServer(middleware)
if (serverTimeout) {
server.timeout = serverTimeout
}

pluginHook('cli:server:created', server, { options: postgraphileOptions, middleware })

// Start our server by listening to a specific port and host name. Also log
Expand Down