@rip-lang/swarm 1.2.5 → 1.2.6
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 +13 -11
package/package.json
CHANGED
package/swarm.rip
CHANGED
|
@@ -87,8 +87,9 @@ hex = (str) ->
|
|
|
87
87
|
[parseInt(m[1], 16), parseInt(m[2], 16), parseInt(m[3], 16)].join(';')
|
|
88
88
|
_hex[str] = result
|
|
89
89
|
|
|
90
|
-
fg
|
|
91
|
-
bg
|
|
90
|
+
fg = (rgb) -> if rgb then "\x1b[38;2;#{hex(rgb)}m" else "\x1b[39m"
|
|
91
|
+
bg = (rgb) -> if rgb then "\x1b[48;2;#{hex(rgb)}m" else "\x1b[49m"
|
|
92
|
+
fgw =! "\x1b[97m" # bright white — more reliable than 24-bit fg("fff")
|
|
92
93
|
|
|
93
94
|
# ==============================================================================
|
|
94
95
|
# Progress display
|
|
@@ -113,13 +114,14 @@ draw = (state) ->
|
|
|
113
114
|
ppct = (done + died) / jobs
|
|
114
115
|
most = Math.max(...Object.values(info), 1)
|
|
115
116
|
|
|
116
|
-
# worker bars
|
|
117
|
+
# worker bars — set colors once, just move cursor per row
|
|
118
|
+
write fgw + bg("5383ec")
|
|
117
119
|
for slot, count of info
|
|
118
120
|
tpct = count / most
|
|
119
121
|
cols = Math.floor(ppct * tpct * wide)
|
|
120
|
-
write go(parseInt(slot) + 1, len + 5) +
|
|
122
|
+
write go(parseInt(slot) + 1, len + 5) + char.repeat(cols)
|
|
121
123
|
|
|
122
|
-
# summary bar
|
|
124
|
+
# summary bar — one atomic write
|
|
123
125
|
dpct = done / jobs
|
|
124
126
|
lpct = live / jobs
|
|
125
127
|
gcol = Math.floor(dpct * wide)
|
|
@@ -129,12 +131,11 @@ draw = (state) ->
|
|
|
129
131
|
|
|
130
132
|
out = [
|
|
131
133
|
go(row, len + 5)
|
|
132
|
-
|
|
133
|
-
bg("
|
|
134
|
-
bg("
|
|
135
|
-
bg("d85140") + " ".repeat(rcol) # red (rest)
|
|
134
|
+
bg("58a65c") + char.repeat(gcol) # green (done)
|
|
135
|
+
bg("f1bf42") + char.repeat(ycol) # yellow (live)
|
|
136
|
+
bg("d85140") + " ".repeat(rcol) # red (rest)
|
|
136
137
|
go(row, len + 5 + wide + 3)
|
|
137
|
-
bg("5383ec") + " #{(ppct * 100).toFixed(1)}% "
|
|
138
|
+
bg("5383ec") + " #{(ppct * 100).toFixed(1)}% " # blue (pct)
|
|
138
139
|
if done > 0 then bg() + " " + bg("58a65c") + " #{done}/#{jobs} done "
|
|
139
140
|
if died > 0 then bg() + " " + bg("d85140") + " #{died} died "
|
|
140
141
|
].filter(Boolean).join('') + fg() + bg()
|
|
@@ -276,6 +277,7 @@ export swarm = (opts = {}) ->
|
|
|
276
277
|
w.on 'message', (msg) ->
|
|
277
278
|
switch msg.type
|
|
278
279
|
when 'error'
|
|
280
|
+
console.error "\nswarm: worker #{slot} failed to start: #{msg.error}"
|
|
279
281
|
writeFileSync('.swarm/errors.log', "worker #{slot} startup: #{msg.error}\n", { flag: 'a' }) if existsSync(_dir)
|
|
280
282
|
when 'ready'
|
|
281
283
|
dispatchNext(w, slot)
|
|
@@ -332,7 +334,7 @@ export swarm = (opts = {}) ->
|
|
|
332
334
|
s = parseInt(slot)
|
|
333
335
|
n = info[slot]
|
|
334
336
|
rate = if secs > 0 then (n / secs).toFixed(1) else '—'
|
|
335
|
-
write go(s + 1, len + 5) +
|
|
337
|
+
write go(s + 1, len + 5) + fgw + bg("5383ec") + char.repeat(wide) + fg() + bg() + " │ #{n} jobs @ #{rate}/sec" + clear(true)
|
|
336
338
|
draw({ live: 0, done, died, jobs, workers, info })
|
|
337
339
|
cursor(true)
|
|
338
340
|
write go(workers + 5, 1)
|