GithubHelp home page GithubHelp logo

Comments (7)

VVD avatar VVD commented on July 18, 2024

Workaround: export PUPPETEER_SKIP_DOWNLOAD=yes before npm install.

from draw-image-export2.

VVD avatar VVD commented on July 18, 2024

Other steps (hacks).
Edit export.js:

 browser = await puppeteer.launch({
+                                                platform: 'linux',
+                                                executablePath: '/usr/local/bin/chrome',
                                                 headless: true,

In tomcat/webapps/draw/js/PreConfig.js (https://github.com/jgraph/drawio/blob/dev/src/main/webapp/js/PreConfig.js):

-window.EXPORT_URL = 'REPLACE_WITH_YOUR_IMAGE_SERVER';
+window.EXPORT_URL = 'http://IP:8000/node/export';

Tried export in PDF - files always have 11 bytes: "BAD REQUEST".

from draw-image-export2.

VVD avatar VVD commented on July 18, 2024

Run log:

$ npm start

> [email protected] start
> node export.js

draw.io export server worker 1 listening on port 8000...
draw.io export server worker 2 listening on port 8000...
info: Success xml=1403 embed=1 format=pdf dt=4113
CLIENT_IP - - [28/Jun/2022:08:01:55 +0000] "POST /node/export HTTP/1.1" 200 58548 "-" "Mozilla/5.0 (X11; Linux x86_64; FreeBSD amd64; rv:99.0) Gecko/20100101 Firefox/99.0"
CLIENT_IP - - [28/Jun/2022:08:02:20 +0000] "GET /node/export HTTP/1.1" 400 - "-" "Mozilla/5.0 (X11; Linux x86_64; FreeBSD amd64; rv:99.0) Gecko/20100101 Firefox/99.0"

from draw-image-export2.

VVD avatar VVD commented on July 18, 2024

Tried different urls and different files:
http://IP:8000/node/export
http://IP:8000/node
http://IP:8000/export
http://IP:8000/node

info: Success xml=2227 embed=1 format=pdf dt=3750
CLIENT_IP - - [28/Jun/2022:08:52:44 +0000] "POST /node/export HTTP/1.1" 200 30262 "-" "Mozilla/5.0 (X11; Linux x86_64; FreeBSD amd64; rv:199.0) Gecko/20100101 Firefox/199.0"
CLIENT_IP - - [28/Jun/2022:08:53:03 +0000] "GET /node/export HTTP/1.1" 400 - "-" "Mozilla/5.0 (X11; Linux x86_64; FreeBSD amd64; rv:199.0) Gecko/20100101 Firefox/199.0"
info: Success xml=6667 embed=1 format=pdf dt=5728
CLIENT_IP - - [28/Jun/2022:09:02:33 +0000] "POST /export HTTP/1.1" 200 220330 "-" "Mozilla/5.0 (X11; Linux x86_64; FreeBSD amd64; rv:199.0) Gecko/20100101 Firefox/199.0"
CLIENT_IP - - [28/Jun/2022:09:02:45 +0000] "GET /export HTTP/1.1" 400 - "-" "Mozilla/5.0 (X11; Linux x86_64; FreeBSD amd64; rv:199.0) Gecko/20100101 Firefox/199.0"
info: Success xml=1403 embed=1 format=pdf dt=3886
CLIENT_IP - - [28/Jun/2022:09:04:03 +0000] "POST /node HTTP/1.1" 200 58546 "-" "Mozilla/5.0 (X11; Linux x86_64; FreeBSD amd64; rv:199.0) Gecko/20100101 Firefox/199.0"
CLIENT_IP - - [28/Jun/2022:09:04:19 +0000] "GET /node HTTP/1.1" 400 - "-" "Mozilla/5.0 (X11; Linux x86_64; FreeBSD amd64; rv:199.0) Gecko/20100101 Firefox/199.0"
info: Success xml=6667 embed=1 format=pdf dt=4943
CLIENT_IP - - [28/Jun/2022:09:06:23 +0000] "POST / HTTP/1.1" 200 220332 "-" "Mozilla/5.0 (X11; Linux x86_64; FreeBSD amd64; rv:199.0) Gecko/20100101 Firefox/199.0"
CLIENT_IP - - [28/Jun/2022:09:06:32 +0000] "GET / HTTP/1.1" 400 - "-" "Mozilla/5.0 (X11; Linux x86_64; FreeBSD amd64; rv:199.0) Gecko/20100101 Firefox/199.0"

from draw-image-export2.

VVD avatar VVD commented on July 18, 2024

It (export server) doesn't work via http if server with nextcloud and/or drawio are on https!
Probably it's a browser fault.

from draw-image-export2.

VVD avatar VVD commented on July 18, 2024

Is it possible to bind on specific IP:PORT without hardcode export.js?
Is this the description:

Then add export=http://localhost:8000/ (hostname and port as needed) as an URL parameter to use that service for development and testing.

How to use it?

from draw-image-export2.

VVD avatar VVD commented on July 18, 2024

Work for me PORT=my_port HOST=my_host_or_IP node export.js with my patches:

--- export.js.orig
+++ export.js
@@ -47,7 +47,9 @@
        const PNG_CHUNK_IDAT = 1229209940;
        const { JSDOM } = require("jsdom");
 
-       const PORT = process.env.PORT || 8000
+       const PORT = process.env.PORT || 8000;
+       const HOST = process.env.HOST || "127.0.0.1";
+       const EXECUTABLE = process.env.EXECUTABLE || "/usr/local/bin/chrome";

        const app = express();
 
@@ -374,6 +376,8 @@
                                                                Buffer.from(decodeURIComponent(html), 'base64')).toString());
 
                                        browser = await puppeteer.launch({
+                                               platform: 'linux',
+                                               executablePath: EXECUTABLE,
                                                headless: true,
                                                args: ['--disable-gpu', '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage']
                                        });
@@ -552,6 +556,8 @@
                                                var t0 = Date.now();
 
                                                browser = await puppeteer.launch({
+                                                       platform: 'linux',
+                                                       executablePath: EXECUTABLE,
                                                        headless: true,
                                                        args: ['--disable-gpu', '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage']
                                                });
@@ -823,7 +829,7 @@
                }
        };
 
-       app.listen(PORT, function () 
+       app.listen(PORT, HOST, function () 
        {
                if (NO_CLUSTER)
                {
@@ -834,4 +840,4 @@
                        console.log(`draw.io export server worker ${cluster.worker.id} listening on port ${PORT}...`);
                }
        });
-}
\ No newline at end of file
+}

Also start script /usr/local/etc/rc.d/draw:

#!/bin/sh

# PROVIDE: draw
# REQUIRE: LOGIN
# KEYWORD: shutdown

. /etc/rc.subr

case $0 in
/etc/rc*)
        # during boot (shutdown) $0 is /etc/rc (/etc/rc.shutdown),
        # so get the name of the script from $_file
        name=$_file
        ;;
*)
        name=$0
        ;;
esac

name=${name##*/}
rcvar=${name}_enable

load_rc_config "${name}"

eval "${rcvar}=\${${rcvar}:-'NO'}"
eval "${name}_user=\${${name}_user:-'${name}'}"
eval "_log=\${${name}_log:-'/var/log/${name}.log'}"
eval "_js=\${${name}_js:-'export.js'}"
eval "HOST=\${${name}_host:-'127.0.0.1'}"
eval "PORT=\${${name}_port:-'8000'}"
eval "EXECUTABLE=\${${name}_executable:-'/usr/local/bin/chrome'}"
eval "pidfile=\${${name}_pid:-'/var/run/${name}/${name}.pid'}"

export HOST PORT EXECUTABLE

command="/usr/sbin/daemon"
command_args="-f -P '${pidfile}' -o '${_log}' /usr/local/bin/node '${_js}'"

run_rc_command "$1"

$ grep draw /etc/rc.conf

draw_enable="YES"
draw_user="draw"
draw_host="127.0.0.1"
draw_ports="8000"
draw_chdir="/opt/draw-image-export2"
draw_log="/opt/log/draw-image-export2.log"
draw_js="export.js"
draw_pid="/var/run/draw-image-export2/draw-image-export2.pid"
draw_executable="/usr/local/bin/ungoogled-chromium"

from draw-image-export2.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.