fix: correct require paths for dist/src output + systemd user
Some checks failed
Deploy API Server / build-and-deploy (push) Has been cancelled
Some checks failed
Deploy API Server / build-and-deploy (push) Has been cancelled
- worker.main.ts: require('../../package.json') for dist/src/ location
- worker-heartbeat.service.ts: require('../../../package.json') + try/catch
- systemd units: User=ubuntu (www-data not present on production)
- EnvironmentFile: /opt/zhixi/env/.env.production
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
cdc228ccf0
commit
bd60c2786f
@ -5,8 +5,8 @@ Wants=mysql.service redis.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=www-data
|
||||
Group=www-data
|
||||
User=ubuntu
|
||||
Group=ubuntu
|
||||
WorkingDirectory=/opt/zhixi/api-server
|
||||
ExecStart=/usr/bin/node dist/src/main.js
|
||||
Restart=always
|
||||
|
||||
@ -7,8 +7,8 @@ After=zhixi-nest-api.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=www-data
|
||||
Group=www-data
|
||||
User=ubuntu
|
||||
Group=ubuntu
|
||||
WorkingDirectory=/opt/zhixi/backend
|
||||
ExecStart=/usr/bin/node dist/src/worker.main.js
|
||||
Restart=always
|
||||
|
||||
@ -57,7 +57,7 @@ async function bootstrap() {
|
||||
const logger = new Logger('WorkerBootstrap');
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const pkg = require('../package.json');
|
||||
const pkg = (() => { try { return require('../../package.json'); } catch { return { version: '0.0.0' }; } })();
|
||||
const instanceId = generateInstanceId();
|
||||
process.env.WORKER_INSTANCE_ID = instanceId;
|
||||
logger.log(`Worker version ${pkg.version} — instance ${instanceId}`);
|
||||
|
||||
@ -120,7 +120,7 @@ export class WorkerHeartbeatService implements OnModuleInit, OnModuleDestroy {
|
||||
const data: WorkerHeartbeatData = {
|
||||
instanceId,
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
appVersion: require('../../package.json').version,
|
||||
appVersion: (() => { try { return require('../../../package.json').version; } catch { return '0.0.0'; } })(),
|
||||
startedAt: this.startedAt.toISOString(),
|
||||
queues: Object.keys(QUEUE_DEFINITIONS),
|
||||
concurrency: Object.values(QUEUE_DEFINITIONS)[0]?.workerOptions.concurrency ?? 1,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user