jurassiscripts / velociraptor

The npm-style script runner for Deno

Home Page:https://velociraptor.run

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

oak/oak_graphql blocks serial execution

borsemayur2 opened this issue · comments

scripts:
  start: 
    - server.ts  # app.listen({port: 8080})
    - client.ts

client.ts script never runs.

Is this issue with oak/oak_graphql or velociraptor? how can I run both scripts serially?

Hi @borsemayur2,

I guess client.ts never runs because server.ts - being a server - is supposed to be running indefinitely. Perhaps you want them to run concurrently?

scripts:
  start:
    pll:
      - server.ts
      - client.ts

@umbopepato I did try pll but the server needs to run before client else it throws an error as below:


TypeError: error sending request for url (http://localhost:8080/graphql): error trying to connect: tcp connect error: Connection refused (os error 111)
    at handleError (deno:core/core.js:186:12)
    at jsonOpParseResult (deno:core/core.js:356:9)
    at asyncHandle (deno:core/core.js:223:40)
    at Array.asyncHandlers.<computed> (deno:core/core.js:238:9)
    at handleAsyncMsgFromRust (deno:core/core.js:207:32)
Watcher Process finished! Restarting on file change...
Server start at http://localhost:8080

I see, the client is calling the server too soon then. The most straightforward solution (although not very elegant) would be to defer the start of the client a bit:

scripts:
  start:
    pll:
      - server.ts
      - cmd:
          - sleep 1 # Estimated server startup time in seconds
          - client.ts

If you want a more precise alternative take a look at wait-for-it.

Thanks. I used wait-for-it as following:

scripts:
  start:
    pll:
      - server/mod.ts
      - cmd:
          - ./wait-for-it.sh localhost:8080 -- vr client
  client: client/mod.ts