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 3 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
4 changes: 4 additions & 0 deletions src/postgraphile/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ program
.option('-b, --disable-graphiql', 'disables the GraphiQL interface. overrides the GraphiQL route option')
.option('-o, --cors', 'enable generous CORS settings. this is 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 (defaults to 120000 = 2 minutes)', parseFloat)
.option('--cluster-workers <count>', '[experimental] spawn <count> workers to increase throughput', parseFloat)

pluginHook('cli:flags:add:webserver', addFlag)
Expand Down Expand Up @@ -192,6 +193,7 @@ const {
schema: dbSchema,
host: hostname = 'localhost',
port = 5000,
timeout: serverTimeout = 120000,
maxPoolSize,
defaultRole: pgDefaultRole,
graphql: graphqlRoute = '/graphql',
Expand Down Expand Up @@ -422,6 +424,8 @@ if (noServer) {
const rawMiddleware = postgraphile(pgConfig, schemas, postgraphileOptions)
const middleware = pluginHook('cli:server:middleware', rawMiddleware, { options: postgraphileOptions })
const server = createServer(middleware)
server.timeout = serverTimeout
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super comfortable using a property access to timeout when there's a setter method setTimeout present; however I'm struggling to tell from the docs if they do the same thing or not:

screenshot 2018-05-03 17 33 43

Can you point to someone of authority stating that these are either equivalent, or that they're different and why you'd use one over the other?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @kronken, any idea regarding this? Are they different?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


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

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