I am using the actionhero framework, it can be started by command actionhero start
. but the problem is that, my cloud node.js app runner can only run an app by specify a main file, such as index.js. How can I adapt my app to be started by a normal node.js file?
You have two choices
Choice #1 You can use child_process
to execute any shell from your node.js application. See this How can I invoke Ruby from Node.js? as a reference. This method is a native node.js way. You don't need to install any external npm.
Choice #2 Use shelljs
to execute such command. ( https://github.com/arturadib/shelljs ) The way it allows you execute the command is quite similar to using child_process
but it makes your code a little neater.
You're looking at something like...
'use strict';
let child_process = require('child_process');
child_process.execFile('node', [`.\path\to\actionhero`, `start`], (err) => {
if(err) console.log(err);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.