您的位置:首页 > 理论基础 > 计算机网络

尝试简单的队列服务(张宴的HTTPSQS)

2010-02-05 15:02 218 查看
声明:本文主要内容摘自张宴的博客http://blog.s135.com/httpsqs/



一、下载&编译&安装

注意:若在ubuntu下make和make install前别忘了加上sudo

详细步骤:

1、安装libevent

wget http://httpsqs.googlecode.com/files/libevent-1.4.13-stable.tar.gz


tar zxvf libevent-1.4.13-stable.tar.gz

cd libevent-1.4.13-stable/

./configure --prefix=/usr

make

make install

cd ../

2、安装键值数据库TokyoCabinet

wget http://httpsqs.googlecode.com/files/tokyocabinet-1.4.41.tar.gz


tar zxvf tokyocabinet-1.4.41.tar.gz

cd tokyocabinet-1.4.41/

./configure

#注:在32位Linux操作系统上编译Tokyo cabinet,请使用./configure --enable-off64代替./configure,可以使数据库文件突破2GB的限制。

#./configure --enable-off64

make

make install

cd ../



/sbin/ldconfig



3、安装队列服务程序HTTPSQS

wget http://httpsqs.googlecode.com/files/httpsqs-1.1.tar.gz


tar zxvf httpsqs-1.1.tar.gz

cd httpsqs-1.1/

make

make install

cd ../



说明:安装TC进行configure时,可能会缺少libbz2包,需要先安装

sudo apt-get install checkinstall build-essential libbz2-dev
(ubuntu下)



二、相关准备说明

查看队列服务程序帮助:

httpsqs -h

-l <ip_addr> 监听的IP地址,默认值为 0.0.0.0

-p <num> 监听的TCP端口(默认值:1218)

-x <path> 数据库目录,目录不存在会自动创建(例如:/opt/httpsqs/data)

-t <second> HTTP请求的超时时间(默认值:1)

-d 以守护进程运行

-h 显示这个帮助



使用范例:

httpsqs -d -p 1218 -x /data0/search/queue



终止进程:

请使用命令“killall httpsqs”、“pkill httpsqs”和“kill httpsqs的进程ID”来停止httpsqs。



三、使用说明

注意:无需apache等httpd服务,使用curl和浏览器即可

若shell尚未安装curl,则需sudo apt-get install curl(ubuntu下)



curl方式测试范例:

1、入队列:

【GET方式】curl "http://host:port/?name=your_queue_name&opt=put&data=经过URL编码的文本消息"

【POST方式】curl -d "经过URL编码的文本消息" "http://host:port/?name=your_queue_name&opt=put"

2、出队列

curl "http://host:port/?charset=utf-8&name=your_queue_name&opt=get"

3、查看队列状态

curl "http://host:port/?name=your_queue_name&opt=status"

4、。。。。。。



四、详细信息请参考

1、http://blog.s135.com/httpsqs/3/1/
作者博客

2、http://code.google.com/p/httpsqs/
项目地址
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: