内容简介:假设我有一个nodejs应用,运行在AWS - 亚马逊云平台上(Amazone Web Service)。我想用本地的Visual Studio Code来远程调试服务器端的nodejs应用。Visual Studio Code的调试配置里定义了两种类型,attach和launch。Visual Studio Code的官方文档对这两种调试启动行为的解释:The best way to explain the difference between launch and attach is think of
假设我有一个nodejs应用,运行在AWS - 亚马逊云平台上(Amazone Web Service)。我想用本地的Visual Studio Code来远程调试服务器端的nodejs应用。
Visual Studio Code的调试配置里定义了两种类型,attach和launch。Visual Studio Code的官方文档对这两种调试启动行为的解释:
The best way to explain the difference between launch and attach is think of a launch configuration as a recipe for how to start your app in debug mode before VS Code attaches to it,
Launch的意思简而言之就是以debug模式启动app。
while an attachconfiguration is a recipe for how to connect VS Code's debugger to an app or process that's alreadyrunning.
而Attach的含义是将Visual Studio Code的调试器绑定到一个已经处于运行状态的应用。
因为我的需求是用本地的Visual Studio Code去调试AWS上正在运行的nodejs应用,毫无疑问应该选Attach。
点击debug configuration这个按钮:
自动弹出存放调试配置信息的launch.json文件了:
把launch.json的内容替换成下面的内容:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Jerry's first debug config",
"address": "127.0.0.1",
"port": 9221
}
]
}
这个配置文件的含义是告诉Visual Studio Code的调试进程,去连接127.0.0.1:9221上的应用调试进程去调试。
当然,最后一步我们还需要将本地的127.0.0.1:9221同AWS上的调试进程使用ssh做一个绑定。
ssh -i C:Usersi042416.sshKOI.pem -L 9221:localhost:9229 ubuntu@amazonaws.com
一切就绪后,做一个操作触发AWS上nodejs应用的执行。比如我在AWS上部署了一个nodejs应用,作为我github repository的webhook。每当我在这个仓库创建issue时,github网站就会推送一个事件到我的webhook上去。
现在我创建了一个名为test create issue的issue,一旦我点了Close按钮,
这个issue close事件会自动发送到我的AWS应用,下图可以看到断点触发了,这样我就实现了使用本地的Visual Studio Code远程调试AWS应用的目的。
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Python Algorithms
Magnus Lie Hetland / Apress / 2010-11-24 / USD 49.99
Python Algorithms explains the Python approach to algorithm analysis and design. Written by Magnus Lie Hetland, author of Beginning Python, this book is sharply focused on classical algorithms, but it......一起来看看 《Python Algorithms》 这本书的介绍吧!