微服务,比如用screen隔离开,然后每个service使用不同端口通信
基础在前:https://www.cnblogs.com/adamans/articles/10532050.html
微服务下用户微服务和celery微服务的交互:
flask app.py 和celery task.py在同一目录:
先启动celery微服务:
screen -S celery_service
cd app:
celery -A app.task.celery worker -l info
再启动flask:
screen -r user_post
uwsgi --http :5002 -w app.main
cd app:
https://api5.xxx.com/user/posts/testing
post application/json
{
"url": "http://s3.xxx.com/ba7571a95d64eaa69a49912f26816e2f.jpg"
}
{
"code": 0,
"data": {
"task_id": "2ca85c18-9710-4735-aadc-26c5d7482828"
},
"message": "Success"
}
https://api5.xxx.com/user/posts/testing/2ca85c18-9710-4735-aadc-26c5d7482828
get
{
"code": 0,
"data": {
"id": "2ca85c18-9710-4735-aadc-26c5d7482828",
"ready": true,
"result": [
"http://s3.xxx.com/ba7571a95d64eaa69a49912f26816e2f.jpg",
60,
"helloworld"
],
"state": "SUCCESS",
"status": "SUCCESS"
},
"message": "Success"
}
文件目录: