Repository URL to install this package:
|
Version:
2.0.11 ▾
|
import portscanner from 'portscanner'
import { createApp, schema } from './app'
import { isPortFree } from './deps/isPortFree'
/**
* is happening 2x...
*/
function startStandalone() {
if (process.env.IS_STANDALONE_GRAPHQL) {
console.log('[uxui-graphql] creating app...')
const app = createApp()
console.log('[uxui-graphql] about to listen...')
const port = process.env.PORT || '4000'
const host = process.env.HOST || 'localhost'
// if (isPortFree(port)) {
// const listener = app.listen(parseInt(process.env.PORT, 10) || 4000, () => {
// console.log('[uxui-graphql] listening on port 4000')
// })
// console.log('[uxui-graphql] async after listening')
// process.on('SIGTERM', () => {
// console.log('[uxui-graphql] SIGTERM')
// listener.close()
// })
// }
portscanner.checkPortStatus(port, (err, status) => {
if (err) {
console.error(err)
}
if (status === 'closed') {
const listener = app.listen(parseInt(port, 10), host, () => {
console.log('[uxui-graphql] listening on port 4000')
})
console.log('[uxui-graphql] async after listening')
process.on('SIGTERM', () => {
console.log('[uxui-graphql] SIGTERM')
listener.close()
})
}
})
} else {
console.log('[uxui-graphql] NOT standalone')
}
}
startStandalone()
// import { ApolloEngine } from 'apollo-engine'
// @todo try try again
// const engine = new ApolloEngine({
// apiKey: 'service:skava-engine:_oygzZUWfir8gDOh7kpgAQ',
// logging: {
// level: 'INFO',
// },
// })
// Start the server
// engine.listen({
// port: 4000,
// expressApp: app,
// })
export { startStandalone, schema }