跨客户端安装同步 Web 应用文件



我们有一个网络应用程序。此网络应用程序是为我们的每个客户端安装在VPS的不同文件夹中的。我们还有一个单独的文件夹,其中包含 Web 应用程序的基本文件(所有代码都是最新的)。

我们遇到的问题是:我们需要为所有客户端安装自动执行 Web 应用程序的更新过程。因此,如果我们向基本 Web 应用添加文件、移动文件、创建目录或删除文件或目录,这些更改应自动反映(应用于)Web 应用的每个客户端安装中。目前我们处于测试阶段,每次代码更新都会使用 FTP 手动更新每个客户端安装的所有文件,完成的更改越多,此过程花费的时间就越多,变得越复杂。

有没有可用于自动化此类过程的工具?或者如果没有,你建议如何处理它?

/
    /clients
        /client1.domain.com
            /[web app subfolders and files...]
        /client2.domain.com
            /[web app subfolders and files...]
        /client3.domain.com
            /[web app subfolders and files...]
    /base_web_app
        /[web app subfolders and files...]

所以基本上,每次我们对/base_web_app 的内容进行任何更改时,这些更改都应该自动应用(同步)到/clients 中的 Web 应用程序安装(即/client1.domain.com、/client2.domain.com、/client3.domain.com)。

同样重要的是要注意,我们需要忽略/不覆盖一些文件和/或子文件夹。主要是特定于每个客户端安装的配置文件。

查看 rsync: http://rsync.samba.org/examples.html 它是一种将文件从一个区域同步到另一个区域(例如您的暂存区域到生产区域)的工具。 您可以使用模式来指定要同步的内容和要排除的内容,并且它仅复制更改的文件。

在暂存区域(您有要同步的最新更改)上,您可以执行以下操作:

# sync staging area base_web_app directory to production base_web_app
# this syncs the entire local base_webapp directory to remote /base_webapp
rsync -avRc base_webapp server:/
# sync staging area base_web_app files to clients/client* directories, excluding the config directory
# this syncs the entire base_webapp to each remote client dir, excluding the config dir
rsync -avRc --exclude 'config/*' base_webapp server:/clients/client1.domain.com
rsync -avRc --exclude 'config/*' base_webapp server:/clients/client2.domain.com
rsync -avRc --exclude 'config/*' base_webapp server:/clients/client3.domain.com

最新更新