SFTP installation of SFTP tools
What I'm choosing here is a tool named SFTP.
Press and enter in Visual Studio Code Ctrl + Shift + P
>extensions install extensions
Select sftp , install and reload
Configuring SFTP
In the workspace, press Ctrl + Shift + P and enter
>sftp config
This command will .vscode add files to sftp.json the
Modify one of the items as required
{ "host": "", //服务器ip "port": 22, //端口,sftp模式是22 "username": "", //用户名 "password": "", //密码 "protocol": "sftp", //模式 "agent": null, "privateKeyPath": null, "passphrase": null, "passive": false, "interactiveAuth": false, "remotePath": "/root/node/build/", //服务器上的文件地址 "context": "./server/build", //本地的文件地址 "uploadOnSave": false, //监听保存并上传 "syncMode": "update", "watcher": { //监听外部文件 "files": false, //外部文件的绝对路径 "autoUpload": false, "autoDelete": false }, "ignore": [ //忽略项 "**/.vscode/**", "**/.git/**", "**/.DS_Store" ]}
Note that the comments cannot be persisted
Use
Press Ctrl + Shift + P and enter
>sftp Upload
Can be uploaded to the server.
Similar directives include the following:
| instruction |
function |
| SFTP Upload |
Upload to server, no then create, overwrite, more ignore |
| SFTP Download |
Download to local, same rules as above |
| SFTP Sync to Remote |
Sync to server, delete more |
| SFTP Sync to Local |
Sync to local, delete more |
PM2 Automatic Reload Installation PM2
npm i -g pm2
Input
pm2 -v
If the version appears as follows, the installation succeeds
[email protected]_0_16_centos ~]# pm2-v
2.9.1
If the version does not appear, instead
[email protected]_0_16_centos ~]# pm2-v
-bash:pm2:command not found
It may be that NPM environment variable is not configured, refer to the CentOS Permanent modification environment variable
Restart the node. JS Service via PM2 and listen for file changes automatically
Using directives
pm2 start server.js --watch
Success is shown as follows:
Automatic uploading with SFTP in Vscode and automatic server restart