Npm运行并行脚本无法正常工作
脚本的目标是保持重试连接到服务器端点,并在可能时生成graphql模式。
如果我在另一个命令提示符下运行脚本,脚本工作正常。 这只是我想在一个命令提示符下运行一个命令。
相反,我得到的错误:
(节点:4212)MaxListenersExceededWarning:检测到可能的EventEmitter内存泄漏。 添加了11个结束监听器。 使用emitter.setMaxListeners()来增加限制
这对我来说没有任何意义,因为听众应该只设置一次,而不是11次。
dotnet-run
只运行asp.net服务器。 显然,这需要一些时间来启动,这就是为什么我写这个脚本,以保持重试到服务器。
"start": "npm-run-all --parallel dotnet-run get-schema:dev", "get-schema:dev": "node scripts/getSchema.js --url http://localhost:8080/graphql"
我正在使用npm-run-all npm软件包
getSchema脚本:
require('isomorphic-fetch'); const getArgs = require('get-args'); const FormData = require('form-data'); const fs = require('fs'); const { buildClientSchema, introspectionQuery, printSchema, } = require('graphql/utilities'); const path = require('path'); const schemaPath = path.join(__dirname, '../schema/schema'); const formData = new FormData(); formData.append('query', introspectionQuery); const args = getArgs(); const url = args.options.url; let intervalId = null; // Save JSON of full schema introspection for Babel Relay Plugin to use const setSchema = () => { fetch(url, { method: 'post', body: formData, }) .then((res) => { if (res.ok) { return res.json(); } throw new Error(res.statusText); }) .then((schemaJSON) => { fs.writeFileSync( `${schemaPath}.json`, JSON.stringify(schemaJSON, null, 2), ); // Save user readable type system shorthand of schema const graphQLSchema = buildClientSchema(schemaJSON.data); fs.writeFileSync( `${schemaPath}.graphql`, printSchema(graphQLSchema), ); clearInterval(intervalId); console.log('Successfuly updated schema.'); }) .catch((error) => { console.log(error); }); }; intervalId = setInterval(setSchema, 1000);
经过一段时间的脚本运行,即使服务器启动,我得到错误:
FetchError:请求到http:// localhost:8080 / graphql失败,原因:套接字挂断
- GraphQL中继返回一条logging
- GraphQL – 传递非特定对象的对象作为参数
- 在Google Cloud App Engine上运行GraphQL服务器
- 发送一个http请求到一个graphql api时“parsingJSON的问题”
- Graphql需要模块外部vs GraphQLObjectType内部
- 如何将查询逻辑添加到基于graphql-sequelize的安装?
- npm开始在Windows机器上失败,但在Ubuntu的工作
- Edge.node字段types必须是输出types,但是:undefined
- 具有明确错误的GraphQL:Query.example字段types必须是输出types,但得到: