gateway_config.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import os
  2. import logging
  3. logging.basicConfig(level=logging.INFO,
  4. format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
  5. datefmt='%a, %d %b %Y %H:%M:%S')
  6. # gateway-alb-ecs组-生产环境
  7. server_group_id_list = ["sgp-l2k0p33e470vfmj538"]
  8. # alb后端服务器_调试使用组
  9. # server_group_id_list = ["sgp-ec4gopoclruofsfmxu"]
  10. apps = 'piaoquan-gateway'
  11. repository = 'registry-vpc.cn-hangzhou.aliyuncs.com/stuuudy/{}'
  12. registry = 'registry-vpc.cn-hangzhou.aliyuncs.com/stuuudy/{}:{}'
  13. # 后端服务器使用的端口
  14. port = "9000"
  15. # 修改负载均衡权限
  16. clb_client_params = {
  17. 'access_key_id': 'LTAIuPbTPL3LDDKN',
  18. 'access_key_secret': 'ORcNedKwWuwVtcq4IRFtUDZgS0b1le',
  19. 'region_id': 'cn-hangzhou'
  20. }
  21. alb_client_params = {
  22. 'access_key_id': 'LTAI5tASD5yEZLeC8ffmNebY',
  23. 'access_key_secret': '1PtsFRdp8viJmI78lEhNZR8MezWZBq',
  24. 'endpoint': 'alb-vpc.cn-hangzhou.aliyuncs.com',
  25. 'region_id': 'cn-hangzhou'
  26. }
  27. # 购买机器权限
  28. ecs_client_params = {
  29. 'access_key_id': 'LTAI4GBWbFvvXoXsSVBe1o9f',
  30. 'access_key_secret': 'kRAikWitb4kDxaAyBqNrmLmllMEDO3',
  31. 'region_id': 'cn-hangzhou'
  32. }
  33. docker_config = {
  34. 'username': 'stuuudys',
  35. 'password': 'Qingqu@2019',
  36. 'registry': 'registry-vpc.cn-hangzhou.aliyuncs.com'
  37. }
  38. # 机器配置
  39. instance_config_j = {
  40. # 使用的镜像信息
  41. 'image_id': 'm-bp1e7t7odil9c8kqsm10',
  42. # 设置实例规格
  43. 'instance_type': 'ecs.c7.xlarge',
  44. # 选择的交换机
  45. 'vswitch_id': 'vsw-bp1ssuwxyrt0p17ceeir0',
  46. # 当前VPC类型的安全组
  47. 'security_group_id': ['sg-bp1irhrkr4vfj272hk4y'],
  48. # 硬盘的大小,单位:G
  49. 'disk_size': ['200'],
  50. # 服务器命名
  51. 'instance_name': 'gateway-alb-[01,2]',
  52. # 服务器所在区域
  53. 'zone_id': 'cn-hangzhou-j',
  54. # 磁盘类型:云盘
  55. 'disk_category': 'cloud_efficiency',
  56. # 密钥
  57. 'key_pair_name': 'stuuudy',
  58. # tag
  59. 'tags': [{"Key": "ecs", "Value": "gateway.prod"}]
  60. }
  61. # 服务启动脚本
  62. start_sh_dir = os.path.dirname(os.path.realpath(__file__))
  63. start_sh_filename = 'gateway_start.sh'
  64. with open(file=os.path.join(start_sh_dir, start_sh_filename), mode='r', encoding='utf-8') as rf:
  65. file_content = rf.read()
  66. logging.info(f"start sh file content: {file_content}")
  67. start_sh = {
  68. 'target_dir': '/home/gateway_server_sh',
  69. 'name': start_sh_filename,
  70. 'content': file_content,
  71. }