尝试简单的队列服务 HTTPSQS

一、下载&编译&安装

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

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

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

详细步骤:

1、安装libevent

wget https://github.com/downloads/libevent/libevent/libevent-2.0.15-stable.tar.gz
tar zxvf libevent-2.0.15-stable.tar.gz
cd libevent-2.0.15-stable/
./configure --prefix=/usr
make
make install
cd ../


2、安装键值数据库TokyoCabinet

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

tar zxvf tokyocabinet-1.4.47.tar.gz
cd tokyocabinet-1.4.47/
./configure --prefix=/usr/local/tokyocabinet-1.4.47/
#注:在32位Linux操作系统上编译Tokyo cabinet,请使用./configure --enable-off64代替./configure,可以使数据库文件突破2GB的限制。
#./configure --enable-off64 --prefix=/usr/local/tokyocabinet-1.4.47/
make
make install

 

3、安装队列服务程序HTTPSQS

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

tar zxvf httpsqs-1.7.tar.gz
cd httpsqs-1.1/
make
make install
cd ../

 

二、相关准备说明

查看队列服务程序帮助:

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 显示这个帮助

 

使用范例:

ulimit -SHn65535
httpsqs
-d -p 1218-x /data0/queue

or with auth password:

ulimit -SHn65535

httpsqs -d -p 1218-x /data0/queue -a mypass123

 

终止进程:

请使用命令“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

 

四、编写自动启动脚本

 

 1 #!/bin/bash
2 # httpsqs shell
3 # author stdanny
4 # version v0.1
5 ############################################
6
7 case "$1" in
8 start)
9 echo -n "Starting httpsqs…"
10 ulimit -SHn 65535
11 httpsqs -d -p 1218 -x /data0/queue -a mypass123
12 cd /usr/bin
13 echo "start httpsqs Ok!"
14 ;;
15 stop)
16 echo -n "Stoping httpsqs…"
17 killall httpsqs
18 echo -n "Stop httpsqs Ok!"
19 ;;
20 *)
21 echo "Usage: $0 {start|stop}"
22 esac
23 exit 0

运行chmod +r /etc/init.d/httpsqs,使之可直接执行

运行chkconfig --add httpsqs,把该服务添加到配置当中

运行chkconfig --list httpsqs,可以查看该服务进程的状态

 

五、详细信息请参考

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

2、http://code.google.com/p/httpsqs/ 项目地址

转载于:https://www.cnblogs.com/stdanny/archive/2011/11/14/2248647.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值