From a5e6330bb1585807f4b10007374931c0fb60541b Mon Sep 17 00:00:00 2001 From: wangjian Date: Tue, 3 Dec 2024 18:21:03 +0800 Subject: [PATCH] optimize pilotgo server deploy method --- scripts/playbook/group_vars/all | 3 +- scripts/playbook/roles/pserver/tasks/main,yml | 20 +------- .../templates/pserver/config_server.yaml.j2 | 51 +++++++++++++++++++ 3 files changed, 54 insertions(+), 20 deletions(-) create mode 100755 scripts/playbook/templates/pserver/config_server.yaml.j2 diff --git a/scripts/playbook/group_vars/all b/scripts/playbook/group_vars/all index 0d9ebf23..c32e4ad3 100644 --- a/scripts/playbook/group_vars/all +++ b/scripts/playbook/group_vars/all @@ -1,3 +1,4 @@ --- redis_password: "PilotGo13579!" -mysql_password: "PilotGo13579!" \ No newline at end of file +mysql_password: "PilotGo13579!" +pserver_config: /opt/PilotGo/server/config_server.yaml \ No newline at end of file diff --git a/scripts/playbook/roles/pserver/tasks/main,yml b/scripts/playbook/roles/pserver/tasks/main,yml index a8f9cf72..3c0b6607 100644 --- a/scripts/playbook/roles/pserver/tasks/main,yml +++ b/scripts/playbook/roles/pserver/tasks/main,yml @@ -10,22 +10,4 @@ msg: 'dnf install PilotGo-server failed' when: pilotgo_info.rc != 0 - name: change PilotGo config - shell: sed -i '/^http_server:/,+1 s/0\.0\.0\.0/{{ ansible_default_ipv4['address'] }}/' /opt/PilotGo/server/config_server.yaml -- name: change PilotGo config - shell: sed -i '/^socket_server:/,+1 s/0\.0\.0\.0/{{ ansible_default_ipv4['address'] }}/' /opt/PilotGo/server/config_server.yaml -- name: change PilotGo config - shell: sed -i '/^mysql:/,+1 s/localhost/{{ ansible_default_ipv4['address'] }}/' /opt/PilotGo/server/config_server.yaml -- name: change passwd - lineinfile: - path: /opt/PilotGo/server/config_server.yaml - regexp: '^#?password' - line: ' password: {{ mysql_password }}' - backrefs: yes -- name: change PilotGo config - shell: sed -i '/^redis:/,+1 s/localhost/{{ ansible_default_ipv4['address'] }}/' /opt/PilotGo/server/config_server.yaml -- name: change passwd - lineinfile: - path: /opt/PilotGo/server/config_server.yaml - regexp: '^#?redis_pwd' - line: ' redis_pwd: {{ redis_password }}' - backrefs: yes \ No newline at end of file + template: src=templates/pserver/config_server.yaml.j2 dest={{ pserver_config }} \ No newline at end of file diff --git a/scripts/playbook/templates/pserver/config_server.yaml.j2 b/scripts/playbook/templates/pserver/config_server.yaml.j2 new file mode 100755 index 00000000..b852c53f --- /dev/null +++ b/scripts/playbook/templates/pserver/config_server.yaml.j2 @@ -0,0 +1,51 @@ +http_server: + addr: 0.0.0.0:8888 + session_count: 100 + session_max_age: 1800 + # if true, will start pprof on :6060 + debug: false + use_https: false + cert_file: "" + key_file: "" +socket_server: + addr: 0.0.0.0:8879 +jwt: + secret_key: "" +log: + level: debug + # 可选stdout和file.stdout:输出到终端控制台;file:输出到path下的指定文件。 + driver: file + path: ./log/pilotgo_server.log + max_file: 1 + max_size: 10485760 +mysql: + {% if groups | length == 1 %} + + host_name: {{ groups['standalone'][0] }} + {% else %} + + host_name: {{ groups['mysql'][0] }} + {% endif %} + # this is the username of database + user_name: root + password: "{{ mysql_password }}" + data_base: PilotGo + port: 3306 +redis: + {% if groups | length == 1 %} + + redis_conn: {{ groups['standalone'][0] }}:6379 + {% else %} + + redis_conn: {{ groups['redis'][0] }}:6379 + {% endif %} + use_tls: false + redis_pwd: "{{ redis_password }}" + defaultDB: 0 + # redis连接超时时间.默认5s + dialTimeout: 5s + # 是否启用redis + enableRedis: true +storage: + # 文件服务存储路径 + path: "/opt/PilotGo/server/resource" -- Gitee