部署脚本的存储位置
假设我的 Python 项目具有以下目录结构:
config/scripts/src/
结构部署脚本应该放在哪里?显然,我认为它应该在脚本中,但对我来说,将启动项目的实际代码存储在脚本中似乎更合适。
Assuming that I have the following directory structure for a Python project:
config/ scripts/ src/
where should a fabric deployment script should go? I assume that it should be in scripts, obviously, but for me it seems more appropriate to store in scripts, the actual code that fires up the project.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这确实是一个偏好问题——但是,根据具体情况,有几个地方我喜欢。
最常见的是,特别是在像您这样的 fabfile 与某个软件绑定的情况下,我喜欢将其放在项目目录中。在这种情况下,我认为 fabfiles 类似于 Makefiles,所以这感觉像是一个自然的地方。 (例如,对于您的示例,将 fabfile 放在包含
config/
scripts/
和src/
的同一目录中)在其他情况下,我使用 fab用于信息收集。具体来说,我运行一些命令并从一系列服务器中提取文件。同样,我在远程主机上启动各种测试。在这些情况下,我喜欢为 fabfile 设置一个特殊目录(称为测试或其他目录)并将数据提取到相关子目录。
最后,我在
$HOME/lib
中保留了一些 fabfile。它们执行一些我经常处理的远程任务。其中之一是用于在我的开发服务器上设置新的 pylons 项目。我已将 rpaste 设置为 fab -f $HOME/lib/rpaste.py 的别名。这允许我随意选择目标动作。This is really a preference thing -- however there are a couple places I like, depending on situation.
Most frequently, and particularly in cases like yours where the fabfile is tied to a piece of software, I like to put it the project directory. I view fabfiles as akin to Makefiles in this case, so this feels like a natural place. (e.g. for your example, put the fabfile in the same directory holding
config/
scripts/
andsrc/
)In other cases, I use fab for information gathering. Specifically I run a few commands and pull files from a series of servers. Similarly I initiate various tests on remote hosts. In these cases I like to set up a special directory for the fabfile (called tests, or whatever) and pull data to the relevant subdirectory.
Finally I have a few fabfiles I keep in
$HOME/lib
. These do some remote tasks that I frequently deal with. One of these is for setting up new pylons projects on my dev server. I have rpaste set up as an alias tofab -f $HOME/lib/rpaste.py
. This allows me to select the target action at will.