通过shell脚本在特定端口启动jsreport服务

Starting jsreport service on a specific port through shell script

我正在提供一个使用 jsreport 的库。服务器通过以下 shell 脚本开始工作 运行 :

npm install jsreport

node node_modules/jsreport --init 

服务 运行s 的默认端口是 443。但是我想 运行 它在另一个端口上。

因为我每次 npm install 它,我不想每次都手动操作配置文件,因为它的结构可能会在以后的 jsreport 版本中发生变化。有没有办法在 shell 脚本命令中指定端口?

可以在

中指定配置
  • 配置文件
  • 节点shell参数
  • 进程环境变量
  • 直接在 javascript 引导程序选项中

对于您的情况,您应该输入 shell

node server.js --httpsPort=5000

对于 http 端口,它将是

node server.js --httpPort=3000 --httpsPort=0 

您需要设置 httpsPort=0 否则 jsreport 开始侦听两个端口并使用 http 响应重定向到 https。