NodeJS不会更改数据库

问题描述 投票:0回答:1

我现在正在使用NodeJS,并且有两个数据库(测试和生产)。

const { Pool } = require('pg');

const Databases = {
    TestDB: new Pool({
        user: '',
        host: '',
        database: 'DEV-TEST',
        password: '',
        port: 5432,
    }),
    ProductionDB: new Pool({
        user: '',
        host: '',
        database: 'PROD',
        password: '',
        port: 5432,
    })
};

// const pool = Databases.TestDB;
const pool = Databases.ProductionDB;

pool.connect();

在PC上运行良好,但是当我将其上传到服务器时,让它与PM2一起运行-NodeJs连接到testDB,而不是Prod。

我该如何解决?

node.js database postgresql pm2
1个回答
0
投票

我已经找到了解决方案。在控制台中,我必须键入pm2 update。我不知道为什么,但这对我有所帮助。因为我使用过重新启动和缓存清理。

© www.soinside.com 2019 - 2024. All rights reserved.