pm2 - 如何使用 pm2 启动带有 AutoReload 的strapi?
问题描述
我按照官方教程成功使用pm2运行了一个小脚本来启动strapi。
const strapi = require('strapi');
strapi().start();
但是 AutoReload 已关闭,并且管理面板不允许我编辑任何内容类型?我应该如何启动 AutoReload?
Strapi 弹出一个警报,告诉我用“yarn develop”命令启动它,但它没有通过 pm2,当我注销终端时它被击落。所以我认为这不是在实际使用中启动的正确方法。
解决方案
如果 strpi 要求您使用yarn develop
,则表示;您不在开发环境中,因此您无法在 Api 中进行更改。
您需要在您的根文件夹中使用一个名为生态系统.config.js 的特殊配置文件,并且您需要设置autorestart: true
.
module.exports = {
apps : [{
name: 'nameofyourapp',
script: 'server.js',
// Options reference: https://pm2.keymetrics.io/docs/usage/application-declaration/
// args: 'one two',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
// not production or staging
env: {
NODE_ENV: 'development'
},
env_production: {
NODE_ENV: 'production'
}
}],
// deploy : {
// production : {
// user : 'node',
// host : '212.83.163.1',
// ref : 'origin/master',
// repo : 'git@github.com:repo.git',
// path : '/var/www/production',
// 'post-deploy' : 'npm install && pm2 reload ecosystem.config.js --env production'
// }
// }
};
然后用pm2 start ecosystem.config.js
命令启动它
推荐阅读
- java - java.lang.IllegalArgumentException:索引 33 处路径中的非法字符:https://box.one.th/app/api/upload
- mongodb - nodejs中连接后如何获取mongodb数据库基本名称?
- java - Android 应用程序在 AVD 中不断崩溃,但在 Gradle 中正确构建
- apache-kafka - 如何指定特定大小的kafka民意调查记录?
- android - 如何在android应用程序中进行兼容性
- python - 如何在生成和检查时应用 xmodem CRC
- python - 有什么办法可以增加分配给 jupyter notebook 的内存
- php - Apache 的 Laravel 文件权限
- c# - C# Microsoft Fakes 测试构造函数中调用的方法
- html - 在本文档中,“原始文本”是什么意思?