nano-pow 4.1.3 → 4.1.4
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/dist/bin/nano-pow.sh +1 -1
- package/dist/bin/server.js +11 -2
- package/package.json +1 -1
package/dist/bin/nano-pow.sh
CHANGED
|
@@ -10,7 +10,7 @@ NANO_POW_LOGS="$NANO_POW_HOME"/logs;
|
|
|
10
10
|
mkdir -p "$NANO_POW_LOGS";
|
|
11
11
|
if [ "$1" = '--server' ]; then
|
|
12
12
|
shift;
|
|
13
|
-
node "$SCRIPT_DIR"/server.js
|
|
13
|
+
node "$SCRIPT_DIR"/server.js >> "$NANO_POW_LOGS"/nano-pow-server-$(date -I).log 2>&1 & echo "$!" > "$NANO_POW_HOME"/server.pid;
|
|
14
14
|
sleep 0.1;
|
|
15
15
|
if [ "$(ps | grep $(cat $NANO_POW_HOME/server.pid))" = '' ]; then
|
|
16
16
|
cat $(ls -td "$NANO_POW_LOGS"/* | head -n1);
|
package/dist/bin/server.js
CHANGED
|
@@ -8,7 +8,15 @@ import * as http from "node:http";
|
|
|
8
8
|
import { homedir } from "node:os";
|
|
9
9
|
import { join } from "node:path";
|
|
10
10
|
function log(...args) {
|
|
11
|
-
if (CONFIG.DEBUG)
|
|
11
|
+
if (CONFIG.DEBUG) {
|
|
12
|
+
const d = new Date(Date.now());
|
|
13
|
+
const opts = {
|
|
14
|
+
hour12: false,
|
|
15
|
+
dateStyle: "medium",
|
|
16
|
+
timeStyle: "medium"
|
|
17
|
+
};
|
|
18
|
+
console.log(d.toLocaleString(navigator.language, opts), `NanoPow[${process.pid}]:`, args);
|
|
19
|
+
}
|
|
12
20
|
}
|
|
13
21
|
process.title = "NanoPow Server";
|
|
14
22
|
const MAX_REQUEST_SIZE = 1024;
|
|
@@ -196,6 +204,7 @@ await unlink(filename);
|
|
|
196
204
|
log("Puppeteer initialized");
|
|
197
205
|
server.listen(CONFIG.PORT, async () => {
|
|
198
206
|
const { port } = server.address();
|
|
199
|
-
|
|
207
|
+
CONFIG.PORT = port;
|
|
208
|
+
log(`Server listening on port ${port}`);
|
|
200
209
|
process.send?.({ type: "listening", port });
|
|
201
210
|
});
|