nginx 更新eccoystem.js.js后使用旧环境变量的Node应用

cyej8jka  于 2023-11-17  发布在  Nginx
关注(0)|答案(1)|浏览(135)

我使用pm2和nginx创建了一个节点服务器,可以同时运行多个应用程序。我刚刚向服务器添加了一个新应用程序,在部署过程中,一些env变量设置错误,不适合生产环境。我编辑了eccosystem.confg.js以删除多余的变量,并运行以下命令:

pm2 reload ecosystem.config.js --update-env 
pm2 save

字符串
在更改生态系统配置后,应用程序仍然显示旧的env vars为set。有什么方法可以告诉env正在设置的位置吗?是否需要清除缓存?我没有首先设置此服务器,所以我对在哪里查看更改env的知识有限。我检查了ecosystem.js.js和sites-avalibble文件夹中的配置文件。
Additional Info
旧的ecosystem.js

{
            name: "new-app-name",
            script: '/var/www/myNewApp.com/NEW-APP/app.js',
            watch_delay: 1000,
            exec_interpreter: "[email protected]",
            watch_delay: 1000,
            watch: true,
            env: {
                            "PORT"         : 4000,
                            "NODE_ENV"     : "production",
                            "PROTOCOL"     : "https",
                            "DOMAIN"       : "myDomain",
                            "EXTENSION"    : "com",
                            "PWD"          : "myPassword",
                            "USE_LONGJOHN" : false,
                            "NODE_TLS_REJECT_UNAUTHORIZED" : 0,
                            "NODE_EXTRA_CA_CERTS":  "/path/to/cert.pem"
                              }
          }


新的ecosystem.js

{
            name: "new-app-name",
            script: '/var/www/myNewApp.com/NEW-APP/app.js',
            watch_delay: 1000,
            exec_interpreter: "[email protected]",
            watch_delay: 1000,
            watch: true,
            env: {
                            "PORT"         : 4000,
                            "NODE_ENV"     : "production",
                            "PROTOCOL"     : "https",
                            "DOMAIN"       : "myDomain",
                            "EXTENSION"    : "com",
                            "PWD"          : "myPassword",
                            "USE_LONGJOHN" : false,
                            "NODE_TLS_REJECT_UNAUTHORIZED" : 1,
                              }
          }


重新加载eccosystem后,env变量已设置

node_version: 18.17.1
version: 1.0.0
unique_id: c96e0ae4-d2a7-49fd-8f41-d1eca6a5edff
ldap: {}
PM2_HOME: /home/pm2/.pm2
NODE_TLS_REJECT_UNAUTHORIZED: 0
NODE_EXTRA_CA_CERTS: /path/to/cert.pem
USE_LONGJOHN: false
EXTENSION: com
DOMAIN: mydomain
PROTOCOL: https
NODE_ENV: production
PORT: 4000
USER: pm2
SSH_CLIENT: 172.0.0.0 56122 22
XDG_SESSION_TYPE: tty
SHLVL: 1
MOTD_SHOWN: pam
HOME: /home/pm2
OLDPWD: /var/www/ldap.com/EDE-LDAP
NVM_BIN: /home/admin/.nvm/versions/node/v14.18.2/bin
SSH_TTY: /dev/pts/0
NVM_INC: /home/admin/.nvm/versions/node/v14.18.2/include/node
DBUS_SESSION_BUS_ADDRESS: unix:path=/run/user/1000/bus
NVM_DIR: /home/admin/.nvm
LOGNAME: pm2
_: 7
XDG_SESSION_CLASS: user
TERM: xterm-256color
XDG_SESSION_ID: 15
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
XDG_RUNTIME_DIR: /run/user/1000
LANG: en_US.UTF-8
SHELL: /bin/sh
LESSCLOSE: /usr/bin/lesspipe %s %s
PWD: myPassword
SSH_CONNECTION: 172.0.0.0 56122 172.0.0.0 22
NVM_CD_FLAGS:
XDG_DATA_DIRS: /usr/local/share:/usr/share:/var/lib/snapd/desktop
PM2_USAGE: CLI
PM2_JSON_PROCESSING: true
NODE_APP_INSTANCE: 0
vizion_running: false
km_link: false
watch_delay: 1000
namespace: default
script: /var/www/myNewApp.com/NEW-APP/app.js

gudnpqoy

gudnpqoy1#

对于其他遇到这个问题的人,我可以通过删除应用程序然后重新启动来修复它。

pm2 delete <appName>
pm2 start <appName>

字符串

相关问题