-
Notifications
You must be signed in to change notification settings - Fork 1
Home
hankya edited this page May 22, 2015
·
1 revision
###如何上线新的mq消费者
- 在部署前,确认消息名(英文)和消费者名(英文)以及回调url, 和对应环境的mongo服务器地址
- 登录到nsq服务器 (目前本地测试环境在192.168.1.6, stage环境应该是103.227.78.158)
- 运行shell命令
sudo su
cd /etc/supervior/conf.d
- 以下面的内容为模板,增加一个supervisord的配置文件(放到/etc/supervior/conf.d下面), 需要根据实际请求替换掉
[program:<消费者名>]
command=/data/worker/worker --topic="<消息名>" --channel="<消费者名>" --post=<回调url> --consumer-opt=max_attempts,10 --consumer-opt=max_backoff_duration,64s --consumer-opt=default_requeue_delay,4s --lookupd-http-address=192.168.1.6:4161 --mongo-server=<mongo服务器ip和端口,比如说192.168.1.2:20000> --mongo-db="<mongo数据库名>"
process_name=<消费者名>
directory=/data/worker
autostart=true
autorestart=true
stderr_logfile=/data/worker/<消费者名>.log
- 执行shell命令supervisorctl update,应该要看到类下下面的输出
root@nsqd-local-01:/etc/supervisor/conf.d# supervisorctl update
<消费者名>: added process group
- 运行supervisorctl status, 应该能看到下面的输出:
root@nsqd-local-01:/data/worker# supervisorctl status
<新加的消费者名> RUNNING pid 21243, uptime 0:06:01
company RUNNING pid 21231, uptime 0:06:51
finance RUNNING pid 20838, uptime 0:55:50
- 执行shell命令ps aux | grep <消费者名>, 应该能看到下面的输出
root@nsqd-local-01:/etc/supervisor/conf.d# ps aux | grep aftersales
root 21243 0.0 0.0 247792 4764 ? Sl 18:15 0:00 /data/worker/worker --topic=order_create --channel=aftersales --post=http://192.168.1.170:8005/dev/nsq.json --consumer-opt=max_attempts,10 --consumer-opt=max_backoff_duration,8s --consumer-opt=default_requeue_delay,4s --lookupd-http-address=192.168.1.6:4161 --mongo-server=192.168.1.2:20000 --mongo-db=worker
- 在/data/worker目录下应该能看见对应的<消费者名>.log文件,正常情况的输出如下:
2015/05/22 18:15:04 INF 1 [order_create/aftersales] querying nsqlookupd http://192.168.1.6:4161/lookup?topic=order_create
2015/05/22 18:15:04 INF 1 [order_create/aftersales] (meicai:4150) connecting to nsqd
2015/05/22 18:15:04 INF 1 [order_create/aftersales] (nsqd-local-01:4148) connecting to nsqd
2015/05/22 18:16:15 INF 1 [order_create/aftersales] querying nsqlookupd http://192.168.1.6:4161/lookup?topic=order_create
2015/05/22 18:17:15 INF 1 [order_create/aftersales] querying nsqlookupd http://192.168.1.6:4161/lookup?topic=order_create