@rip-lang/swarm 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/swarm.rip +12 -3
package/package.json
CHANGED
package/swarm.rip
CHANGED
|
@@ -200,12 +200,17 @@ export swarm = (opts = {}) ->
|
|
|
200
200
|
workerPath = join(dirname(new URL(import.meta.url).pathname), 'lib', 'worker.mjs')
|
|
201
201
|
scriptPath = resolve(process.argv[1] or '')
|
|
202
202
|
|
|
203
|
-
# find rip-loader for workers
|
|
203
|
+
# find rip-loader for workers (check local, then global)
|
|
204
204
|
loaderPath = null
|
|
205
205
|
try
|
|
206
206
|
loaderPath = join(dirname(require.resolve('rip-lang')), '..', 'rip-loader.js')
|
|
207
207
|
catch
|
|
208
|
-
|
|
208
|
+
# fall back to global install
|
|
209
|
+
try
|
|
210
|
+
globalDir = join(process.env.HOME or '', '.bun', 'install', 'global', 'node_modules', 'rip-lang')
|
|
211
|
+
loaderPath = join(globalDir, 'rip-loader.js') if existsSync(join(globalDir, 'rip-loader.js'))
|
|
212
|
+
catch
|
|
213
|
+
null
|
|
209
214
|
|
|
210
215
|
# state
|
|
211
216
|
live = 0
|
|
@@ -266,6 +271,8 @@ export swarm = (opts = {}) ->
|
|
|
266
271
|
|
|
267
272
|
w.on 'message', (msg) ->
|
|
268
273
|
switch msg.type
|
|
274
|
+
when 'error'
|
|
275
|
+
writeFileSync('.swarm/errors.log', "worker #{slot} startup: #{msg.error}\n", { flag: 'a' }) if existsSync(_dir)
|
|
269
276
|
when 'ready'
|
|
270
277
|
dispatchNext(w, slot)
|
|
271
278
|
when 'done'
|
|
@@ -280,6 +287,7 @@ export swarm = (opts = {}) ->
|
|
|
280
287
|
when 'failed'
|
|
281
288
|
move(msg.taskPath, _died)
|
|
282
289
|
lastTask[slot] = msg.taskPath.split('/').pop()
|
|
290
|
+
writeFileSync('.swarm/errors.log', "#{msg.taskPath.split('/').pop()}: #{msg.error or 'unknown'}\n", { flag: 'a' }) if existsSync(_dir)
|
|
283
291
|
inflight[slot] = null
|
|
284
292
|
live--
|
|
285
293
|
died++
|
|
@@ -288,9 +296,10 @@ export swarm = (opts = {}) ->
|
|
|
288
296
|
dispatchNext(w, slot)
|
|
289
297
|
|
|
290
298
|
w.on 'error', (err) ->
|
|
291
|
-
|
|
299
|
+
writeFileSync('.swarm/errors.log', "worker #{slot} error: #{err.message}\n", { flag: 'a' }) if existsSync(_dir)
|
|
292
300
|
|
|
293
301
|
w.on 'exit', (code) ->
|
|
302
|
+
writeFileSync('.swarm/errors.log', "worker #{slot} exited with code #{code}, inflight: #{inflight[slot]}\n", { flag: 'a' }) if existsSync(_dir)
|
|
294
303
|
# if worker crashed mid-task, count the in-flight task as died
|
|
295
304
|
if inflight[slot]
|
|
296
305
|
move(inflight[slot], _died)
|