如何更改symfony部署任务中rsync的顺序

发布于 2024-11-30 02:51:46 字数 1634 浏览 2 评论 0原文

我想部署我的 symfony 应用程序的一部分,比如说,它就像一个模块。

我想先排除所有文件,然后仅包含以下文件 我的新模块。

对于部署,我使用以下 symfony 任务

 php symfony project:deploy production -t

参数 -t 将所有文件打印到包含在 rsync 试运行中的输出。

config/rsync_exclude.txt 的内容只有 *,因为我喜欢排除所有内容:

*

在 config/rsync_include.txt 中,我列出了要包含的所有文件和文件夹:

config/
config/mysupermodule.yml
lib/model/doctrine/
lib/model/doctrine/MySuperclass.php
lib/model/doctrine/MySuperclassTable.php
lib/
lib/MySuperLibrary/
lib/MySuperLibrary/*

symfony 任务构建以下 rsync 命令:

rsync --dry-run -azC --force --delete --progress --exclude-from=config/rsync_exclude.txt --include-from=config/rsync_include.txt -e "ssh -p22" ./ [email protected]:/test_deployment/

问题 1:该任务不同步任何文件。

解决方案 1:更改顺序:先包含,然后排除。

我发现,如果我将需求更改为这个:

我想包含新模块的所有文件并排除所有文件 其他。

这意味着使用以下命令:

rsync --dry-run -azC --force --delete --progress --include-from=config/rsync_include.txt --exclude-from=config/rsync_exclude.txt -e "ssh -p22" ./ [email protected]:/test_deployment/

rsync 工作。

问题2:使用symfony任务时如何更改rsync的顺序? symfony 任务首先排除而不是包含。

解决方案 2:?

I want to deploy a part of my symfony application, say, it's like a module.

I want to exclude all files first, and then include only the files of
my new module.

For deployment I use the following symfony task

 php symfony project:deploy production -t

The parameter -t prints all files to the output that are included in this dry run of rsync.

Content of config/rsync_exclude.txt is only *, since I like to exclude everthing:

*

In config/rsync_include.txt I list all the files and folders for the inclusion:

config/
config/mysupermodule.yml
lib/model/doctrine/
lib/model/doctrine/MySuperclass.php
lib/model/doctrine/MySuperclassTable.php
lib/
lib/MySuperLibrary/
lib/MySuperLibrary/*

The symfony task builds the following rsync command:

rsync --dry-run -azC --force --delete --progress --exclude-from=config/rsync_exclude.txt --include-from=config/rsync_include.txt -e "ssh -p22" ./ [email protected]:/test_deployment/

Problem 1: The the task doesn't sync any files.

Solution to 1: Change order: Include first, then exclude.

I figured out, that if I change my need to this one:

I want to include all files of my new module and exclude then all
other.

This means using the following command:

rsync --dry-run -azC --force --delete --progress --include-from=config/rsync_include.txt --exclude-from=config/rsync_exclude.txt -e "ssh -p22" ./ [email protected]:/test_deployment/

The rsync works.

Problem 2: How can I change the order of the rsync when using the symfony task?
The symfony task first excludes than includes.

Solution 2: ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

扛起拖把扫天下 2024-12-07 02:51:46

这是不可能的。

但您可以在 lib/task/project/sfProjectDeployTask.class.php 中编辑部署任务。

将其(SF 1.4 中的第 145 至 154 行): 替换

  if (file_exists($options['rsync-dir'].'/rsync_exclude.txt'))
  {
    $parameters .= sprintf(' --exclude-from=%s/rsync_exclude.txt', $options['rsync-dir']);
  }

  if (file_exists($options['rsync-dir'].'/rsync_include.txt'))
  {
    $parameters .= sprintf(' --include-from=%s/rsync_include.txt', $options['rsync-dir']);
  }

为:

  if (file_exists($options['rsync-dir'].'/rsync_include.txt'))
  {
    $parameters .= sprintf(' --include-from=%s/rsync_include.txt', $options['rsync-dir']);
  }

  if (file_exists($options['rsync-dir'].'/rsync_exclude.txt'))
  {
    $parameters .= sprintf(' --exclude-from=%s/rsync_exclude.txt', $options['rsync-dir']);
  }

简而言之:切换这两个 IF 语句。

It is NOT possible.

But you can edit the deployment task in lib/task/project/sfProjectDeployTask.class.php.

Replace this (line 145 to 154 in SF 1.4):

  if (file_exists($options['rsync-dir'].'/rsync_exclude.txt'))
  {
    $parameters .= sprintf(' --exclude-from=%s/rsync_exclude.txt', $options['rsync-dir']);
  }

  if (file_exists($options['rsync-dir'].'/rsync_include.txt'))
  {
    $parameters .= sprintf(' --include-from=%s/rsync_include.txt', $options['rsync-dir']);
  }

with this:

  if (file_exists($options['rsync-dir'].'/rsync_include.txt'))
  {
    $parameters .= sprintf(' --include-from=%s/rsync_include.txt', $options['rsync-dir']);
  }

  if (file_exists($options['rsync-dir'].'/rsync_exclude.txt'))
  {
    $parameters .= sprintf(' --exclude-from=%s/rsync_exclude.txt', $options['rsync-dir']);
  }

In short: switch this two IF statements.

腻橙味 2024-12-07 02:51:46

让我们改变你想做的方式。
您应该仅使用排除文件。仅排除已更改但您不想同步的目录。

因为无论如何,如果 module/、app/、... 目录没有更改,则不必将它们放入排除文件中,因为它们在两台服务器上都保持不变。

Let's change the way you want to do.
You should use only the exclude file. Exclude only directories that changed but you don't want to sync.

Because anyway if you modules/, app/, ... directories haven't change, you don't have to put them in the exclude file because they will remain the same on both server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文