longvideoapi_config.py 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. # alb后端服务器_调试使用组
  7. server_group_id_list = ["sgp-ec4gopoclruofsfmxu"]
  8. # longvideoapi-alb-ecs组-生产环境
  9. # server_group_id_list = ["sgp-h79h3lkvua1xs3418y"]
  10. # 后端服务器使用的端口
  11. port = "8080"
  12. # 修改负载均衡权限
  13. alb_client_params = {
  14. 'access_key_id': 'LTAI5tASD5yEZLeC8ffmNebY',
  15. 'access_key_secret': '1PtsFRdp8viJmI78lEhNZR8MezWZBq',
  16. 'endpoint': 'alb-vpc.cn-hangzhou.aliyuncs.com',
  17. 'region_id': 'cn-hangzhou'
  18. }
  19. # 购买机器权限
  20. ecs_client_params = {
  21. 'access_key_id': 'LTAI4GBWbFvvXoXsSVBe1o9f',
  22. 'access_key_secret': 'kRAikWitb4kDxaAyBqNrmLmllMEDO3',
  23. 'region_id': 'cn-hangzhou'
  24. }
  25. # 机器配置
  26. instance_config = {
  27. # 使用的镜像信息
  28. 'image_id': 'm-bp12bkuvg20k6ueqmb4v',
  29. # 设置实例规格
  30. 'instance_type': 'ecs.c6.2xlarge',
  31. # 选择的交换机
  32. 'vswitch_id': 'vsw-bp19lpjwtc6j0p0m9mdc2',
  33. # 当前VPC类型的安全组
  34. 'security_group_id': 'sg-bp1irhrkr4vfj272hk4y',
  35. # 硬盘的大小,单位:G
  36. 'disk_size': '200',
  37. # 服务器命名
  38. 'instance_name': 'ESS-vlogapi-[1,2]',
  39. # 服务器所在区域
  40. 'zone_id': 'cn-hangzhou-h',
  41. # 磁盘类型:云盘
  42. 'disk_category': 'cloud_efficiency',
  43. # 密钥
  44. 'key_pair_name': 'stuuudy',
  45. # tag
  46. 'tags': [{"Key": "ecs", "Value": "longvideoapi.prod"}]
  47. }
  48. # 机器配置_hangzhou_i
  49. instance_config_i = {
  50. # 使用的镜像信息
  51. 'image_id': 'm-bp12bkuvg20k6ueqmb4v',
  52. # 设置实例规格
  53. 'instance_type': 'ecs.c6.2xlarge',
  54. # 选择的交换机
  55. 'vswitch_id': 'vsw-bp17c002ovyomzwnhhdhj',
  56. # 当前VPC类型的安全组
  57. 'security_group_id': 'sg-bp1irhrkr4vfj272hk4y',
  58. # 硬盘的大小,单位:G
  59. 'disk_size': '200',
  60. # 服务器命名
  61. 'instance_name': 'ESS-vlogapi-[1,2]',
  62. # 服务器所在区域
  63. 'zone_id': 'cn-hangzhou-i',
  64. # 磁盘类型:云盘
  65. 'disk_category': 'cloud_efficiency',
  66. # 密钥
  67. 'key_pair_name': 'stuuudy',
  68. # tag
  69. 'tags': [{"Key": "ecs", "Value": "longvideoapi.prod"}]
  70. }
  71. # 机器配置_hangzhou_g
  72. instance_config_g = {
  73. # 使用的镜像信息
  74. 'image_id': 'm-bp12bkuvg20k6ueqmb4v',
  75. # 设置实例规格
  76. 'instance_type': 'ecs.c6.2xlarge',
  77. # 选择的交换机
  78. 'vswitch_id': 'vsw-bp10m69sb9ydfa64jdrn3',
  79. # 当前VPC类型的安全组
  80. 'security_group_id': 'sg-bp1irhrkr4vfj272hk4y',
  81. # 硬盘的大小,单位:G
  82. 'disk_size': '200',
  83. # 服务器命名
  84. 'instance_name': 'ESS-vlogapi-[1,2]',
  85. # 服务器所在区域
  86. 'zone_id': 'cn-hangzhou-g',
  87. # 磁盘类型:云盘
  88. 'disk_category': 'cloud_efficiency',
  89. # 密钥
  90. 'key_pair_name': 'stuuudy',
  91. # tag
  92. 'tags': [{"Key": "ecs", "Value": "longvideoapi.prod"}]
  93. }
  94. # 机器配置_hangzhou_j
  95. instance_config_j = {
  96. # 使用的镜像信息
  97. 'image_id': 'm-bp12bkuvg20k6ueqmb4v',
  98. # 设置实例规格
  99. 'instance_type': 'ecs.c6.2xlarge',
  100. # 选择的交换机
  101. 'vswitch_id': 'vsw-bp1ssuwxyrt0p17ceeir0',
  102. # 当前VPC类型的安全组
  103. 'security_group_id': 'sg-bp1irhrkr4vfj272hk4y',
  104. # 硬盘的大小,单位:G
  105. 'disk_size': '200',
  106. # 服务器命名
  107. 'instance_name': 'ESS-vlogapi-[1,2]',
  108. # 服务器所在区域
  109. 'zone_id': 'cn-hangzhou-j',
  110. # 磁盘类型:云盘
  111. 'disk_category': 'cloud_efficiency',
  112. # 密钥
  113. 'key_pair_name': 'stuuudy',
  114. # tag
  115. 'tags': [{"Key": "ecs", "Value": "longvideoapi.prod"}]
  116. }
  117. # 机器配置_hangzhou_k
  118. instance_config_k = {
  119. # 使用的镜像信息
  120. 'image_id': 'm-bp12bkuvg20k6ueqmb4v',
  121. # 设置实例规格
  122. 'instance_type': 'ecs.c6.2xlarge',
  123. # 选择的交换机
  124. 'vswitch_id': 'vsw-bp14e4xu6uzte9nyn6nvr',
  125. # 当前VPC类型的安全组
  126. 'security_group_id': 'sg-bp1irhrkr4vfj272hk4y',
  127. # 硬盘的大小,单位:G
  128. 'disk_size': '200',
  129. # 服务器命名
  130. 'instance_name': 'ESS-longvideoapi-alb-[1,2]',
  131. # 服务器所在区域
  132. 'zone_id': 'cn-hangzhou-k',
  133. # 磁盘类型:云盘
  134. 'disk_category': 'cloud_efficiency',
  135. # 密钥
  136. 'key_pair_name': 'stuuudy',
  137. # tag
  138. 'tags': [{"Key": "ecs", "Value": "longvideoapi.prod"}]
  139. }
  140. # 机器配置_hangzhou_k alb
  141. instance_config_k_alb = {
  142. # 使用的镜像信息
  143. 'image_id': 'm-bp12bkuvg20k6ueqmb4v',
  144. # 设置实例规格
  145. 'instance_type': 'ecs.c6.2xlarge',
  146. # 选择的交换机
  147. 'vswitch_id': 'vsw-bp14e4xu6uzte9nyn6nvr',
  148. # 当前VPC类型的安全组
  149. 'security_group_id': 'sg-bp1irhrkr4vfj272hk4y',
  150. # 硬盘的大小,单位:G
  151. 'disk_size': '200',
  152. # 服务器命名
  153. 'instance_name': 'ESS-vlogapi-alb-[1,2]',
  154. # 服务器所在区域
  155. 'zone_id': 'cn-hangzhou-k',
  156. # 磁盘类型:云盘
  157. 'disk_category': 'cloud_efficiency',
  158. # 密钥
  159. 'key_pair_name': 'stuuudy',
  160. # tag
  161. 'tags': [{"Key": "ecs", "Value": "longvideoapi.prod"}]
  162. }
  163. # 服务启动脚本
  164. start_sh_dir = os.path.dirname(os.path.realpath(__file__))
  165. start_sh_filename = 'longvideo_start.sh'
  166. with open(file=os.path.join(start_sh_dir, start_sh_filename), mode='r', encoding='utf-8') as rf:
  167. file_content = rf.read()
  168. # logging.info(f"start sh file content: {file_content}")
  169. start_sh = {
  170. 'target_dir': '/home/piaoquan_server_sh',
  171. 'name': start_sh_filename,
  172. 'content': file_content,
  173. }