【问题标题】:How to run node server and java server in same command line in package.json start如何在 package.json 启动的同一命令行中运行节点服务器和 java 服务器
【发布时间】:2023-04-01 06:33:01
【问题描述】:

我需要跑步:

node server.js

还有:

java -Xmx4g -cp 'libraries/corenlp/*' edu.stanford.nlp.pipeline.StanfordCoreNLPServer -serverProperties StanfordCoreNLP-french.properties -port 9000 -timeout 15000

我试过了:

node server.js; java -Xmx4g -cp 'libraries/corenlp/*' edu.stanford.nlp.pipeline.StanfordCoreNLPServer -serverProperties StanfordCoreNLP-french.properties -port 9000 -timeout 15000

或者

node server.js && java -Xmx4g -cp 'libraries/corenlp/*' edu.stanford.nlp.pipeline.StanfordCoreNLPServer -serverProperties StanfordCoreNLP-french.properties -port 9000 -timeout 15000

但是在这两种情况下,当我在节点应用程序中询问 java 服务器时,它都没有运行。但是,如果我在 2 个不同的控制台中同时运行这两个命令。 没有问题。 谢谢

编辑:我尝试在 npm start 中执行此操作

【问题讨论】:

  • 您使用哪个操作系统来运行这些进程?
  • @KrishnaKuntala Debian

标签: java node.js linux npm package.json


【解决方案1】:

好的,所以我找到了一种方法: 我的 package.json:

"scripts": {
    "start-nlp" : "java -Xmx4g -cp 'libraries/corenlp/*' edu.stanford.nlp.pipeline.StanfordCoreNLPServer -serverProperties StanfordCoreNLP-french.properties -port 9000 -timeout 15000 &",
    "start-node": "node server.js",
    "start": "npm run start-nlp && npm run start-node"

},

【讨论】:

    【解决方案2】:

    您需要在后台运行这些进程。请在命令末尾附加& 以在后台运行它们。

    node server.js &
    
    java -Xmx4g -cp 'libraries/corenlp/*' edu.stanford.nlp.pipeline.StanfordCoreNLPServer -serverProperties StanfordCoreNLP-french.properties -port 9000 -timeout 15000 &
    

    要杀死它们,您需要使用ps -ef | grep 命令搜索这些进程。

    【讨论】:

    • 我尝试从 npm start 运行它,我得到:sh: 1: Syntax error: ";"出乎意料
    猜你喜欢
    • 2020-02-05
    • 2016-12-13
    • 2020-11-17
    • 1970-01-01
    • 2023-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-28
    相关资源
    最近更新 更多