highcharts-export-server 从网站运行时不生成 svg

问题描述 投票:0回答:1

我们有一个 php 8.1 的网站。应该使用 exec 运行 highcharts-export-server 来生成 svg 文件,但该文件没有生成:

$cmd = '/var/www/mysite/node/node_modules/lib/node_modules/highcharts-export-server/bin/cli.js --infile /tmp/node_files/nso_2024-07-10__12.50.00_77003733f89002aca7337718298f07df.json --outfile /tmp/node_files/nso_2024-07-10__12.50.00_77003733f89002aca7337718298f07df.svg';
exec($cmd, $out, $retval);

**当我直接在命令行上运行此命令时,它运行良好并且创建了 svg。 **

$retval 输出:

retval: [1]

这是 $out 的输出:

out: [Array
(
    [0] =>     __  ___       __         __               __
    [1] =>    / / / (_)___ _/ /_  _____/ /_  ____ ______/ /______
    [2] =>   / /_/ / / __ `/ __ \/ ___/ __ \/ __ `/ ___/ __/ ___/
    [3] =>  / __  / / /_/ / / / / /__/ / / / /_/ / /  / /_(__  )
    [4] => /_/ /_/_/\__, /_/ /_/\___/_/ /_/\__,_/_/   \__/____/
    [5] =>         ____//___/                  __     _____
    [6] =>        / ____/  ______  ____  _____/ /_   / ___/___  ______   _____  _____
    [7] =>       / __/ | |/_/ __ \/ __ \/ ___/ __/   \__ \/ _ \/ ___/ | / / _ \/ ___/
    [8] =>      / /____>  </ /_/ / /_/ / /  / /_    ___/ /  __/ /   | |/ /  __/ /
    [9] =>     /_____/_/|_/ .___/\____/_/   \__/   /____/\___/_/    |___/\___/_/
    [10] =>               /_/
    [11] =>                                                                      v3.1.1
)
]

仅此而已。当我从命令行运行它时,我得到:

    __  ___       __         __               __
   / / / (_)___ _/ /_  _____/ /_  ____ ______/ /______                    
  / /_/ / / __ `/ __ \/ ___/ __ \/ __ `/ ___/ __/ ___/                    
 / __  / / /_/ / / / / /__/ / / / /_/ / /  / /_(__  )                     
/_/ /_/_/\__, /_/ /_/\___/_/ /_/\__,_/_/   \__/____/                      
        ____//___/                  __     _____                          
       / ____/  ______  ____  _____/ /_   / ___/___  ______   _____  _____
      / __/ | |/_/ __ \/ __ \/ ___/ __/   \__ \/ _ \/ ___/ | / / _ \/ ___/
     / /____>  </ /_/ / /_/ / /  / /_    ___/ /  __/ /   | |/ /  __/ /    
    /_____/_/|_/ .___/\____/_/   \__/   /____/\___/_/    |___/\___/_/     
              /_/                                                         
                                                                     v3.1.1
Wed Jul 10 2024 12:46:43 GMT-0400 [notice] - [cache] Dependency cache is up to date, proceeding.
Wed Jul 10 2024 12:46:43 GMT-0400 [verbose] - [cache] writing new manifest
Wed Jul 10 2024 12:46:43 GMT-0400 [notice] - [browser] attempting to get a browser instance (try 0)
Wed Jul 10 2024 12:46:43 GMT-0400 [notice] - [pool] Initializing pool: min 1, max 1.
Wed Jul 10 2024 12:46:43 GMT-0400 [verbose] - [pool] Attaching exit listeners to the process.
Wed Jul 10 2024 12:46:44 GMT-0400 [notice] - [pool] Successfully created a worker e4cb0f2c-6d16-4afa-a54c-62f841a17a47 - took 229 ms.
Wed Jul 10 2024 12:46:44 GMT-0400 [notice] - [pool] The pool is ready with 1 initial resources waiting.
Wed Jul 10 2024 12:46:44 GMT-0400 [verbose] - [chart] Starting exporting process.
Wed Jul 10 2024 12:46:44 GMT-0400 [verbose] - [chart] Attempting to export from an input file.
Wed Jul 10 2024 12:46:44 GMT-0400 [verbose] - [pool] Work received, starting to process.
Wed Jul 10 2024 12:46:44 GMT-0400 [verbose] - [pool] Acquiring worker
Wed Jul 10 2024 12:46:44 GMT-0400 [notice] - [browser] Could not clear page
Wed Jul 10 2024 12:46:44 GMT-0400 [verbose] - [pool] Releasing a worker of an id e4cb0f2c-6d16-4afa-a54c-62f841a17a47
Wed Jul 10 2024 12:46:44 GMT-0400 [verbose] - [pool] Acquired worker handle
Wed Jul 10 2024 12:46:44 GMT-0400 [verbose] - [pool] Starting work on pool entry e4cb0f2c-6d16-4afa-a54c-62f841a17a47.
Wed Jul 10 2024 12:46:44 GMT-0400 [verbose] - [export] Determining export path.
Wed Jul 10 2024 12:46:44 GMT-0400 [verbose] - [export] Treating as config.
Wed Jul 10 2024 12:46:44 GMT-0400 [verbose] - [pool] Work completed in 134 ms.
Wed Jul 10 2024 12:46:44 GMT-0400 [notice] - [pool] Killing all workers.
Wed Jul 10 2024 12:46:44 GMT-0400 [notice] - [pool] Destroying pool entry e4cb0f2c-6d16-4afa-a54c-62f841a17a47.
Wed Jul 10 2024 12:46:44 GMT-0400 [verbose] - [pool] Destroyed a worker of an id e4cb0f2c-6d16-4afa-a54c-62f841a17a47
Wed Jul 10 2024 12:46:44 GMT-0400 [notice] - [browser] Could not clear page
Wed Jul 10 2024 12:46:44 GMT-0400 [verbose] - [pool] Releasing a worker of an id e4cb0f2c-6d16-4afa-a54c-62f841a17a47
Wed Jul 10 2024 12:46:44 GMT-0400 [notice] - [pool] Killing all workers.

我怀疑这可能是权限问题,我更改了节点文件夹中的所有内容以对用户和组使用 www-data,但我仍然得到上面的输出。没有 php (nginx) 错误。因为我在节点输出或 php 端没有看到任何错误,所以我不确定如何继续。我也不确定 retval 1 表示什么。

php node.js highcharts exec
1个回答
0
投票
  1. 您应该尝试当前的

    master
    分支(v4.0.0),它已经解决了许多性能和运行状况问题:https://github.com/highcharts/node-export-server。这或许可以解决问题。

  2. 您使用 $out 读取的是控制台日志的内容,而不是 SVG。日志输出未满。

  3. $retval
    很可能是节点(导出)进程的返回值,其中0表示进程结束时没有任何失败,1表示进程结束时出现某种失败。

  4. $retval
    将不包含SVG输出,而是包含上述进程退出代码。不幸的是,由于唯一的日志是 Highcharts 徽标,因此您必须启用完整日志记录(设置
    --logLevel 4
    标志)并提供完整日志,然后我们才能知道导出过程中到底出了什么问题。

您遇到的错误应该告诉您导出过程中到底出了什么问题,并调查为什么在终端中手动运行的命令不会发生此错误。

© www.soinside.com 2019 - 2024. All rights reserved.