Skip to content

Commit

Permalink
feat: 调整sock文件位置
Browse files Browse the repository at this point in the history
  • Loading branch information
bangbang93 committed Jan 30, 2024
1 parent 3e4a23b commit 60c2451
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN apt-get update && \

WORKDIR /opt/openbmclapi
COPY package-lock.json package.json ./
RUN npm ci --prod
RUN npm ci --omit=dev

COPY --from=install /opt/openbmclapi/dist ./dist
COPY nginx/ /opt/openbmclapi/nginx
Expand Down
5 changes: 3 additions & 2 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ events {
worker_connections 10240;
accept_mutex on;
}
user <%= user %>;
pid <%= root %>/nginx.pid;
worker_rlimit_nofile 65535;
http {
Expand Down Expand Up @@ -57,7 +58,7 @@ http {
}

location / {
proxy_pass http://unix:<%= root %>/cache/openbmclapi.sock;
proxy_pass http://unix:<%= sock %>;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand All @@ -66,7 +67,7 @@ http {

location = /auth {
internal;
proxy_pass http://unix:<%= root %>/cache/openbmclapi.sock;
proxy_pass http://unix:<%= sock %>;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
Expand Down
11 changes: 5 additions & 6 deletions src/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import colors from 'colors/safe.js'
import express, {type NextFunction, type Request, type Response} from 'express'
import {readFileSync} from 'fs'
import fse from 'fs-extra'
import {chmod, mkdtemp, open, readdir, readFile, rm, stat, unlink} from 'fs/promises'
import {mkdtemp, open, readdir, readFile, rm, stat, unlink} from 'fs/promises'
import got, {type Got, HTTPError} from 'got'
import {createServer, Server} from 'http'
import {createSecureServer} from 'http2'
import http2Express from 'http2-express-bridge'
import {clone, min, sum, template} from 'lodash-es'
import morgan from 'morgan'
import ms from 'ms'
import {userInfo} from 'node:os'
import {tmpdir} from 'os'
import pMap from 'p-map'
import {basename, dirname, join, sep} from 'path'
Expand Down Expand Up @@ -234,7 +235,7 @@ export class Cluster {
}

public async setupNginx(pwd: string, appPort: number, proto: string): Promise<void> {
this._port = join(this.cacheDir, 'openbmclapi.sock')
this._port = '/tmp/openbmclapi.sock'
await rm(this._port, {force: true})
const dir = await mkdtemp(join(tmpdir(), 'openbmclapi'))
const confFile = `${dir}/nginx/nginx.conf`
Expand All @@ -247,6 +248,8 @@ export class Cluster {
root: pwd,
port: appPort,
ssl: proto === 'https',
sock: this._port,
user: userInfo().username,
}))

const logFile = join(__dirname, '..', 'access.log')
Expand Down Expand Up @@ -288,10 +291,6 @@ export class Cluster {
}
this.server.listen(this._port, resolve)
})
if (typeof this._port === 'string') {
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
await chmod(this._port, 0o777)
}
}

public async connect(): Promise<void> {
Expand Down

0 comments on commit 60c2451

Please sign in to comment.