Automatic uploading with SFTP in Vscode and automatic server restart

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.