use path.resolve for parsing path strings

This commit is contained in:
HF 2023-12-28 23:52:21 +01:00
parent f62c5e0474
commit 33a1ca1c97
4 changed files with 11 additions and 7 deletions

View File

@ -2,6 +2,7 @@
* creation of captchas
*/
import path from 'path';
import { Worker } from 'worker_threads';
import logger from './logger';
@ -11,7 +12,7 @@ const MAX_WAIT = 30 * 1000;
/*
* worker thread
*/
const worker = new Worker('./workers/captchaloader.js');
const worker = new Worker(path.resolve('./workers/captchaloader.js'));
/*
* queue of captcha-generation tasks

View File

@ -4,6 +4,7 @@
*/
import fs from 'fs';
import path from 'path';
import { Worker } from 'worker_threads';
import logger from './logger';
@ -23,7 +24,7 @@ const CanvasUpdaters = {};
/*
* worker thread
*/
const worker = new Worker('./workers/tilewriter.js');
const worker = new Worker(path.resolve('./workers/tilewriter.js'));
/*
* queue of tasks that is worked on in FIFO

View File

@ -3,6 +3,7 @@
* REDIS_URL can be url or path to unix socket
*/
import fs from 'fs';
import path from 'path';
import { createClient, defineScript } from 'redis';
import { isMainThread } from 'worker_threads';
@ -11,7 +12,7 @@ import { REDIS_URL, SHARD_NAME } from '../../core/config';
const scripts = {
placePxl: defineScript({
NUMBER_OF_KEYS: 9,
SCRIPT: fs.readFileSync('./workers/lua/placePixel.lua'),
SCRIPT: fs.readFileSync(path.resolve('./workers/lua/placePixel.lua')),
transformArguments(...args) {
return args.map((a) => ((typeof a === 'string') ? a : a.toString()));
},
@ -19,7 +20,7 @@ const scripts = {
}),
allowedChat: defineScript({
NUMBER_OF_KEYS: 3,
SCRIPT: fs.readFileSync('./workers/lua/allowedChat.lua'),
SCRIPT: fs.readFileSync(path.resolve('./workers/lua/allowedChat.lua')),
transformArguments(...args) {
return args.map((a) => ((typeof a === 'string') ? a : a.toString()));
},
@ -27,7 +28,7 @@ const scripts = {
}),
getUserRanks: defineScript({
NUMBER_OF_KEYS: 2,
SCRIPT: fs.readFileSync('./workers/lua/getUserRanks.lua'),
SCRIPT: fs.readFileSync(path.resolve('./workers/lua/getUserRanks.lua')),
transformArguments(...args) {
return args.map((a) => ((typeof a === 'string') ? a : a.toString()));
},
@ -35,7 +36,7 @@ const scripts = {
}),
zmRankRev: defineScript({
NUMBER_OF_KEYS: 1,
SCRIPT: fs.readFileSync('./workers/lua/zmRankRev.lua'),
SCRIPT: fs.readFileSync(path.resolve('./workers/lua/zmRankRev.lua')),
transformArguments(key, uids) {
return [
key,

View File

@ -21,12 +21,13 @@ const basePackageValues = {
private: true,
engines: pkg.engines,
scripts: {
start: 'node --nouse-idle-notification --expose-gc server.js',
start: 'pm2 restart ecosystem.yml',
},
dependencies: {
mysql2: '',
'utf-8-validate': '',
bufferutil: '',
pm2: '^5.3.0',
},
};