简体   繁体   English

Mac 到 EC2 - 源代码控制三角问题 - git? 同步? 什么?

[英]Mac to EC2 - the source control Triangle Problem - git? rsync? WTH?

I have an everyday EC2 instance.我每天都有一个 EC2 实例。 (Indeed, note that those change IPs each time you restart them, a further problem.) (确实,请注意,每次重新启动它们时,它们都会更改 IP ,这是一个进一步的问题。)

There's a folder/ on the instance and I have a simple (say) Node project in folder (mysql, express etc).实例上有一个文件夹/,我在文件夹(mysql、express 等)中有一个简单的(比如)Node 项目。 It's a web site, let's say.比方说,这是一个网站。

So developing on my Mac ... how do you wrangle this?所以在我的 Mac 上开发......你如何解决这个问题?

Could run a git repo on the EC2 instance, edit locally on my Mac and push .. but the URL is always changing, nuisance.可以在 EC2 实例上运行 git repo,在我的 Mac 上本地编辑并推送 .. 但 URL 总是在变化,令人讨厌。

Visual Studio Community does not unfortunately have any remote-editing, I believe. Visual Studio的社区没有不幸有任何远程编辑,我相信。

(And really, you want to end up with the code stored in a repo somewhere, anyway.) (实际上,无论如何,您都希望将代码存储在某个存储库中。)

I could just have a git repo (or svn repo) on one of my own servers, and go in a triangle each time .. push .. pull .. seems inconvenient.我可以在我自己的一台服务器上拥有一个 git repo(或 svn repo),并且每次都进入一个三角形......推..拉.. 似乎不方便。

You'd have to constantly push, pull manually.你必须不断地推,手动拉。

I'm happy to just use Nano on the shell but, you know, you don't get autocomplete and pretty colors.我很高兴在 shell 上使用 Nano,但是,你知道,你不会得到自动完成和漂亮的颜色。

Astonishingly, I find the best solution seems to be, using the $2 (perfectly engineered) Transmit sftp client on Mac ... they included an "edit with .. choose .. Visual Studio" button - hooray Transmit!令人惊讶的是,我发现最好的解决方案似乎是,在 Mac 上使用 2 美元(设计完美)的Transmit sftp 客户端……它们包括一个“使用 .. 选择 .. Visual Studio 进行编辑”按钮 - 万岁传输! Every time you save it sends up to the instance.每次保存时,它都会发送到实例。 That works, but Vis.那行得通,但 Vis. doesn't understand it's a full "solution", it's just file by file, which is lame.不明白这是一个完整的“解决方案”,它只是一个文件一个文件,这是蹩脚的。

It seems remarkable there is no everyday solution to this "Triangle problem" - how to ?这个“三角形问题”没有日常解决方案,这似乎很了不起——如何解决?

I can think of two ways to solve this: 我可以想到两种解决方法:

  1. Create an Elastic IP and associate it with your instance. 创建一个弹性IP并将其与您的实例关联。 Then your IP doesn't change. 这样您的IP不会改变。 (Personally I would create a DNS name for it anyway. It's easier to remember it when you need to, and it can be descriptive of what the host is.) (无论如何,我个人都会为它创建一个DNS名称。在需要时更容易记住它,它可以描述主机的名称。)

Couldn't be easier, but hard to find 很难,但很难找到

  • go to your EC2 instance 转到您的EC2实例
  • left column click "Elastic IPs" under "Network & Security" . 在左列中,点击“ 网络与安全”下的 “弹性IP (Not "Elastic Block Store") (不是“ Elastic Block Store”)
  • simply click "Allocate" - done 只需点击“分配”-完成

在此处输入图片说明

  1. Use a dynamic DNS solution such as the one outlined here . 使用动态DNS解决方案,例如此处概述的解决方案。 Then your git URL can be a fixed name instead of a changing IP. 然后,您的git URL可以是固定名称,而不是更改的IP。 Once you configure it your instance can update the DNS record whenever its IP changes. 一旦配置它,您的实例就可以在其IP更改时更新DNS记录。

I see the elastic IP allowing you to push directly.我看到弹性 IP 允许您直接推送。 A couple of additional options几个附加选项

Check out the aws-cli integration options which both deploy code (usually to s3) and then start ec2 instances that are attached to the code to run websites.查看 aws-cli 集成选项,它们都部署代码(通常到 s3),然后启动附加到代码的 ec2 实例以运行网站。

Or you could publish your work to github (public or private repo) and have a mechanism to have the EC2 instance connect & pull to its local storage (I'm assuming it has some persistent-ish).或者您可以将您的工作发布到 github(公共或私有存储库),并拥有一种机制让 EC2 实例连接并拉到其本地存储(我假设它有一些持久性)。

Choices for notification include periodic fetch of a version file, method in your webapp to kick off etc.通知的选择包括定期获取版本文件、在您的 web 应用程序中启动的方法等。

Maybe just do it when the instance restarts & just restart it each time (rather brutish)也许只是在实例重新启动时执行它并且每次都重新启动它(相当粗鲁)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM