如何在 pm2 之前运行node server.js -p
?
我的package.json
的脚本如下所示,
"scripts": {
"dev": "node server.js",
"start": "node server.js -p"
},
当我执行npm start
时,一切都会真正生效。但是我想用 pm2 运行此命令。
要在我运行pm2 start npm -- start
时执行此操作,该过程将添加到 pm2 的列表中,但我的应用程序无法运行!
答案 0 :(得分:1)
正确的命令是
from pathlib import Path, PureWindowsPath
from subprocess import PIPE,Popen
def backup():
version = 11
# postgresDir = "D:/Program Files (x86)/PostgreSQL/9.1/bin"
postgresDir = str("D:/Program Files (x86)/PostgreSQL/9.1/bin/").split('\\')[-1:][0]
directory = postgresDir
filename = 'myBackUp2' # output filename here
saveDir = Path("D:/{}.tar".format(filename)) # output directory here
file = PureWindowsPath(saveDir)
host = 'localhost'
user = 'postgres'
port = '5432'
dbname = 'BPS_Server' # database name here
proc = Popen(['pg_dump', '-h', host, '-U', user, '-W', '-p', port,
'-F', 't', '-f', str(file), '-d', dbname],
cwd=directory, shell=True, stdin=PIPE)
proc.wait()
backup()
或者如果您要将pm2 start server.js
传递给您的应用和名称
-p