简体   繁体   English

使用pm2和bytenode启动NodeJS应用程序

[英]Start NodeJS application using pm2 and bytenode

I am converting my NodeJS code to V8 bytecode using this module . 我正在使用此模块将NodeJS代码转换为V8字节码。 I have installed it locally and when try to execute the command ./node_modules/bytenode/cli.js index.jsc it works and for starting using pm2 if I install the module globally and execute the command pm2 start "bytenode index.jsc" then also it works. 我已经在本地安装了它,当尝试执行命令./node_modules/bytenode/cli.js index.jsc它可以工作,并且如果我在全局安装模块并执行命令pm2 start "bytenode index.jsc"pm2 start "bytenode index.jsc"然后也可以。 But the problem I am facing is when I try to start with pm2 using the local installation of bytenode as I want to avoid the global installation of the same. 但是我面临的问题是当我尝试使用bytenode的本地安装从pm2开始时,因为我想避免全局安装。 I want to achieve something like this pm2 start "./node_modules/bytenode/cli.js index.jsc" but could not get it to work any help would be appreciated. 我想实现类似pm2 start "./node_modules/bytenode/cli.js index.jsc"但无法使其正常工作,将不胜感激。

Note: If I define ./node_modules/bytenode/cli.js index.jsc in the package.json start command and execute pm2 start "npm run start" it works, but I want to achieve the same from command line without using the npm run command. 注意:如果我在package.json start命令中定义./node_modules/bytenode/cli.js index.jsc并执行pm2 start "npm run start"那么它可以工作,但是我想在命令行中实现相同功能而不使用npm run命令。

Update: I even tried defining the command "./node_modules/bytenode/cli.js index.jsc" in the script key by generating the ecosystem.config.js and running pm2 start ecosystem.config.js but still no success. 更新:我什至尝试通过在脚本密钥中定义命令"./node_modules/bytenode/cli.js index.jsc" ,方法是生成ecosystem.config.js "./node_modules/bytenode/cli.js index.jsc"并运行pm2 start ecosystem.config.js "./node_modules/bytenode/cli.js index.jsc"但仍然没有成功。

Update launcher.js file with below lines: 使用以下几行更新launcher.js文件:

require('bytenode');
require('./index.jsc');

And then you need to run launcher.js with pm2 : 然后,您需要使用pm2运行launcher.js

pm2 start launcher.js

I hope it will work. 我希望它能起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM