2017-12-01 08:25:19 +03:00
|
|
|
require! \stream-snitch
|
|
|
|
pty = require \pty.js
|
|
|
|
|
2017-12-02 00:00:10 +03:00
|
|
|
urbit =
|
2017-12-01 08:44:10 +03:00
|
|
|
# TODO abort on failure
|
2017-12-01 08:25:19 +03:00
|
|
|
pty.spawn './urbit' <[-B urbit.pill -A .. -cFI zod zod]>
|
|
|
|
.on \data -> process.stdout.write it
|
|
|
|
|
2017-12-01 08:52:30 +03:00
|
|
|
fin = no
|
2017-12-02 00:00:10 +03:00
|
|
|
urbit.pipe (new stream-snitch /dojo> /g).on \match ->
|
2017-12-01 08:52:30 +03:00
|
|
|
return if fin
|
|
|
|
fin := yes
|
2017-12-01 08:34:57 +03:00
|
|
|
console.log "\n\n---\nnode: got dojo!\n---\n\n"
|
|
|
|
set-timeout (-> process.exit 0), 1000 # should probably test further
|
2017-12-01 08:25:19 +03:00
|
|
|
|
2017-12-02 00:00:10 +03:00
|
|
|
urbit.pipe (new stream-snitch /ford: /g).on \match ->
|
2017-12-01 08:52:30 +03:00
|
|
|
return if fin
|
|
|
|
fin := yes
|
2017-12-01 08:34:57 +03:00
|
|
|
console.log "\n\n---\nnode: detected error\n---\n\n"
|
|
|
|
set-timeout (-> process.exit 1), 1000
|
2017-12-01 08:25:19 +03:00
|
|
|
|
|
|
|
set-timeout ...
|
|
|
|
-> console.log "\n\n---\nnode: timed out after 5 min\n---"
|
|
|
|
5*60000
|
2017-12-02 00:00:10 +03:00
|
|
|
|
|
|
|
process.on \exit -> urbit.write '\x04' # send EOF to gracefully checkpoint
|