Preview service fixes (#530)

This commit is contained in:
Cristian Balas
2022-01-19 21:03:39 +02:00
committed by GitHub
parent 368ec67733
commit f3e74e0e64
8 changed files with 1048 additions and 771 deletions
+2 -2
View File
@@ -45,8 +45,8 @@ services:
dockerfile: packages/preview-service/Dockerfile
image: speckle/speckle-preview-service:local
restart: always
mem_limit: "1000m"
memswap_limit: "1000m"
mem_limit: "3000m"
memswap_limit: "3000m"
environment:
DEBUG: "preview-service:*"
PG_CONNECTION_STRING: "postgres://speckle:speckle@postgres/speckle"
+3 -3
View File
@@ -2,7 +2,7 @@
# build stage
FROM node:16.13-buster-slim as build-stage
FROM node:14.16-buster-slim as build-stage
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
@@ -31,7 +31,7 @@ RUN npm run build-fe
FROM node:16.13-buster-slim as node
FROM node:14.16-buster-slim as node
RUN apt-get update && apt-get install -y \
tini \
@@ -54,5 +54,5 @@ COPY --from=build-stage /opt/preview-service /opt/preview-service
WORKDIR /opt/preview-service
ENTRYPOINT [ "tini", "--" ]
CMD ["node", "bin/www"]
+21
View File
@@ -0,0 +1,21 @@
build:
docker build -t preview-service ../.. -f Dockerfile
run:
docker run -it --rm --net=host \
-e DEBUG="preview-service:*" \
-e PG_CONNECTION_STRING="postgres://speckle:speckle@localhost/speckle" \
preview-service
run-release:
docker run -it --rm --net=host \
-e DEBUG="preview-service:*" \
-e PG_CONNECTION_STRING="postgres://speckle:speckle@localhost/speckle" \
speckle/speckle-preview-service:v2.3.3
small:
docker build -t small-preview-service ../.. -f Dockerfile.small
docker run -it --rm --net=host -e DEBUG="preview-service:*" -e PG_CONNECTION_STRING="postgres://speckle:speckle@localhost/speckle" small-preview-service bash
@@ -110,6 +110,11 @@ async function startPreviewService() {
console.log( 'Shutting down...' )
} )
process.on( 'SIGINT', () => {
shouldExit = true
console.log( 'Shutting down...' )
} )
tick()
}
+1 -1
View File
@@ -3,6 +3,6 @@
module.exports = require( 'knex' )( {
client: 'pg',
connection: process.env.PG_CONNECTION_STRING || 'postgres://speckle:speckle@localhost/speckle',
pool: { min: 1, max: 1 }
pool: { min: 1, max: 2 }
// migrations are in managed in the server package
} )
+1009 -760
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -29,7 +29,7 @@
"pg": "^8.6.0",
"pg-query-stream": "^4.1.0",
"prom-client": "^13.1.0",
"puppeteer": "^9.0.0",
"puppeteer": "^13.1.1",
"yargs": "^17.3.0",
"zlib": "^1.0.5"
},
+6 -4
View File
@@ -22,8 +22,7 @@ async function pageFunction( objectUrl ) {
let t0 = Date.now()
let stepAngle = 0.261799
v.postprocessing = false
v.sceneManager.skipPostLoad = true
try {
await v.loadObject( objectUrl, '' )
} catch ( error ) {
@@ -32,7 +31,7 @@ async function pageFunction( objectUrl ) {
}
v.interactions.zoomExtents( 0.95, false )
await waitForAnimation()
await waitForAnimation( 100 )
ret.scr['0'] = v.interactions.screenshot()
for ( let i = 1; i < 3; i++ ) {
@@ -47,6 +46,7 @@ async function pageFunction( objectUrl ) {
await waitForAnimation()
ret.scr[i + ''] = v.interactions.screenshot()
}
/*
v.interactions.rotateCamera( 2 * stepAngle, transition=false )
await waitForAnimation( 500 )
@@ -62,11 +62,12 @@ async function pageFunction( objectUrl ) {
ret.duration = ( Date.now() - t0 ) / 1000
ret.mem = { total: performance.memory.totalJSHeapSize, used: performance.memory.usedJSHeapSize }
ret.userAgent = navigator.userAgent
return ret
}
async function getScreenshot( objectUrl ) {
let launchParams = { args: [ '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage' ] }
let launchParams = { headless: true, args: [ '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage' ] }
// if ( process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD === 'true' ) {
// launchParams.executablePath = 'chromium'
// }
@@ -116,6 +117,7 @@ async function getScreenshot( objectUrl ) {
return `
<html><body>
<div>Generated by: ${ret.userAgent}</div>
<div>Duration in seconds: ${ret.duration}</div>
<div>Memory in MB: ${ret.mem.total / 1000000}</div>
<div>Used Memory in MB: ${ret.mem.used / 1000000}</div>