通常,我们使用“ strapi start”启动stradi。
我将其托管在AWS ubuntu上:
尝试“启动stradi&”以使其在后台运行。但是,一旦终端关闭,我们将无法再访问stridi控制台。
答案 0 :(得分:2)
使用@ user1872384的解决方案时出现script not found: server.js
错误。
因此,这是在后台模式下运行stradi的正确方法。
NODE_ENV =生产pm2开始-名称APP_NAME npm-开始
这只会告诉pm2使用npm start
命令,然后让npm执行which script to run
部分。
希望它可以帮助某人。
答案 1 :(得分:2)
要在开发模式下运行trapi,请在项目文件夹中使用以下pm2命令。
pm2 start npm --name my-project -- run develop
和
pm2 list
查看状态
答案 2 :(得分:1)
需要使用pm2:
开始:
npm install pm2 -g
NODE_ENV=production pm2 start server.js --name api
列出所有进程:
pm2 list
┌──────────┬────┬────────┬──────────────┬ ────┬──────────┬──────┬────────────────┬ ┬──────────┐
│应用程序名称│id│版本│模式│pid│状态│重新启动│正常运行时间│cpu│mem│用户│观看│
├──────────┼────┼────────┼────┼──────┼ ────┼──────────┼──────┼────────────────┼ ┼──────────┤
│api│0│0.1.0│fork│21817│在线│0│2m│0%│108.0 MB│ubuntu│禁用│
└──────────┴────┴────────┴──────────────┴ ────┴──────────┴──────┴────────────────┴ ┴──────────┘
要停止,请使用ID:
pm2 stop 0
答案 3 :(得分:1)
第一
npm install pm2 -g
将server.js添加到项目的根目录并在下面的行中编写:
const strapi = require('strapi');
strapi().start();
然后保存
pm2 start server.js
答案 4 :(得分:0)
这是有关starting Strapi with PM2的官方页面。
从trapi命令开始
默认情况下,有两个重要命令。
yarn develop
以在开发模式下启动您的项目。
yarn start
以启动您的应用进行生产。
您还可以使用yarn start或development命令启动流程管理器。
pm2 start npm --name my-app -- run develop
答案 5 :(得分:0)
最好的方法是使用 pm2 及其 ecosystem.config.js 文件。
npm i -g pm2@latest
module.exports = {
apps: [
{
name: 'give-your-app-a-name',
script: 'npm',
args: 'start',
watch: true, // automatically restart the server for file changes
max_memory_restart: '450M',
env: {
NODE_ENV: 'production',
},
},
{
name: 'give-your-another-app-a-name',
script: 'npm',
args: 'start',
env: {
NODE_ENV: 'production',
},
},
],
}
pm2 start ecosystem.config.js
就是这样。
答案 6 :(得分:0)
我们也可以按类型从pm2开始
<块引用>pm2 开始“纱线开发”
答案 7 :(得分:-1)
pm2 start npm --name my-app -- run develop