您的位置:首页 > 其它

sersync2 完全安装配置说明(三) ----插件基本配置和使用

2012-04-27 13:45 716 查看
插件相关xml

<sersync>

......

<plugin start="false"
name="command"/>

</sersync>

<plugin name="command">

<param prefix="/bin/sh"
suffix=""
ignoreError="true"/>

<filter start="false">

<include expression="(.*)\.php"/>

<include expression="(.*)\.sh"/>

</filter>

</plugin>

<plugin name="socket">

<localpath watch="/opt/tongbu">

<deshost ip="192.168.138.20"
port="8009"/>

</localpath>

</plugin>

<plugin name="refreshCDN">

<localpath watch="/data0/htdocs/cms.xoyo.com/site/">

<cdninfo domainname="ccms.chinacache.com"
port="80"
username="xxxx"
passwd="xxxx"/>

<sendurl base="http://pic.xoyo.com/cms"/>

<regexurl regex="false"
match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/>

</localpath>

</plugin>

如 上面的xml所示,其中plugin标签设置为true时候,在同步文件或路径到远程之后后,调用插件。通过name参数指定需要执行的插件。目前支持的有command refreshCDN socket http四种插件。http插件目前由于兼容性原因去除,以后会重新加入。

command插件

当文件同步完成后,会调用command插件,如同步文件是test.php,则test.php文件在改动之后,调用rsync同步到远程服务器后,调用command插件,执行

/bin/sh test.php suffix
>/dev/null 2>&1

如果suffix 设置了,则会放在inotify事件test.php之后

如果ignoreError为true,则会添加>/dev/null 2>&1

当然还可以设置command的filter,当filter为ture,include可以只对正则匹配到的文件,调用command。

刷新CDN插件

“refreshCDN”,就在同步过程中将文件发送到目 的服务器后刷新cdn接口。如果不想使用,则将start属性设为false即可。如果需要使用其他插件,则查看其他plugin标签,将插件名称改为 xml中其它插件的名称即可。

以下模块(refreshCDN http socket)可以单独使用,只需在命令行下使用-m 参数即可。如果需要作为插件与同步程序一起使用,见同步程序说明的插件配置。

该模块根据chinaCDN的协议,进行设计,当有文件产生的时候,就向cdn接口发送需要刷新的路径位置。刷新CDN模块需要配置的xml文件如下。

<plugin name="refreshCDN">

<localpath watch="/data0/htdocs/cms.xoyo.com/site/">

<cdninfo domainname="ccms.chinacache.com"
port="80"
username="xxxx"
passwd="xxxx"/>

<sendurl base="http://pic.xoyo.com/cms"/>

<regexurl regex="false"
match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/>

</localpath>

</plugin>

其中 localpath watch 是需要监控的目录。

cdnifo标签制定了cdn接口的域名,端口号,以及用户名与密码。

sendurl标签是需要刷新的url的前缀。

regexurl标签中的,regex属性为true时候,使用match属性的正则语句匹配inotify返回的路径信息,并将正则匹配到的部分作为url一部分,

举例:

如果产生文件事件为:/data0/htdoc/cms.xoyo.com/site/jx3.xoyo.com/image/a/123.txt

经过上面的match正则匹配后,最后刷新的路径是:

如果regex属性为false,最后刷新的路径是

socket插件

socket插件,开启该模块,则向指定ip与端口发送inotify所产生的文件路径信息:

Http插件

http插件,可以向指定域名的主机post,inotify监控的事件

其中mask是事件掩膜,8为修改保存,其它inotify事件掩码,见google。

单独运行插件

插件也可以单独使用,即不对远程目标机进行同步,直接调用插件:

只调用command插件

./sersync -d -m command

只调用refreshCDN插件

./sersync -d -m refreshCDN

只调用socket插件

./sersync -d -m socket

只调用http插件

./sersync -d -m http

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: