Prechádzať zdrojové kódy

:hammer: add lily/morus/tulip services

Jeremy Zheng 2 rokov pred
rodič
commit
f45fcbed65

+ 4 - 0
deploy/group_vars/all.yml

@@ -7,3 +7,7 @@ app_php_version: "8.1"
 app_downloads: "{{ ansible_env.HOME }}/downloads"
 app_backup: "{{ ansible_env.HOME }}/backups"
 app_dashboard_base_path: "/pcd"
+
+app_morus_listen_port: 10061
+app_lily_listen_port: 10062
+app_tulip_listen_port: 10063

+ 17 - 60
deploy/roles/mint-v2/tasks/laravel.yml

@@ -1,6 +1,6 @@
 # https://laravel.com/docs/10.x/deployment
 
-- name: clone source code
+- name: clone source code(laravel)
   ansible.builtin.git:
     repo: "https://github.com/iapt-platform/mint.git"
     dest: "{{ app_deploy_root }}/htdocs"
@@ -95,6 +95,13 @@
     cmd: su www-data -pc "php artisan view:cache"
     chdir: "{{ app_deploy_root }}/htdocs"
 
+- name: setup sqlite3 db for v1
+  become: true
+  ansible.builtin.file:
+    src: /var/www/shared/appdata
+    dest: "{{ app_deploy_root }}/htdocs/storage/app/data"
+    state: link
+
 # https://laravel.com/docs/10.x/scheduling#running-the-scheduler
 - name: upload scheduler service
   become: true
@@ -114,64 +121,14 @@
     group: root
     mode: "0644"
 
-- name: upload {{ action }} worker service
-  become: true
-  template:
-    src: v2/queue-worker.service.j2
-    dest: /usr/lib/systemd/system/mint-{{ app_deploy_env }}-{{ action }}-worker.service
-    owner: root
-    group: root
-    mode: "0644"
-  vars:
-    action: "discussion"
-
-- name: upload {{ action }} worker service
-  become: true
-  template:
-    src: v2/queue-worker.service.j2
-    dest: /usr/lib/systemd/system/mint-{{ app_deploy_env }}-{{ action }}-worker.service
-    owner: root
-    group: root
-    mode: "0644"
-  vars:
-    action: "pr"
+- import_tasks: queue-workers.yml
 
-- name: upload {{ action }} worker service
-  become: true
-  template:
-    src: v2/queue-worker.service.j2
-    dest: /usr/lib/systemd/system/mint-{{ app_deploy_env }}-{{ action }}-worker.service
-    owner: root
-    group: root
-    mode: "0644"
-  vars:
-    action: "progress"
-
-- name: upload {{ action }} worker service
-  become: true
-  template:
-    src: v2/queue-worker.service.j2
-    dest: /usr/lib/systemd/system/mint-{{ app_deploy_env }}-{{ action }}-worker.service
-    owner: root
-    group: root
-    mode: "0644"
-  vars:
-    action: "wbw.analyses"
-
-- name: upload {{ action }} worker service
-  become: true
-  template:
-    src: v2/queue-worker.service.j2
-    dest: /usr/lib/systemd/system/mint-{{ app_deploy_env }}-{{ action }}-worker.service
-    owner: root
-    group: root
-    mode: "0644"
-  vars:
-    action: "export.pali.chapter"
+- name: clone source code(agile)
+  ansible.builtin.git:
+    repo: "https://github.com/iapt-platform/mint.git"
+    dest: "{{ app_deploy_root }}/agile"
+    version: "agile"
 
-- name: setup sqlite3 db for v1
-  become: true
-  ansible.builtin.file:
-    src: /var/www/shared/appdata
-    dest: "{{ app_deploy_root }}/htdocs/storage/app/data"
-    state: link
+- import_tasks: morus.yml
+- import_tasks: lily.yml
+- import_tasks: tulip.yml

+ 23 - 0
deploy/roles/mint-v2/tasks/lily.yml

@@ -0,0 +1,23 @@
+- name: upload lily config.toml
+  template:
+    src: v2/lily/config.toml.j2
+    dest: "{{ app_deploy_root }}/agile/rpc/lily/config.toml"
+    mode: "0644"
+
+- name: upload lily rpc server service
+  become: true
+  template:
+    src: v2/lily/services/server.service.j2
+    dest: /usr/lib/systemd/system/mint-{{ app_deploy_env }}-lily.service
+    owner: root
+    group: root
+    mode: "0644"
+
+- name: upload lily rpc worker service
+  become: true
+  template:
+    src: v2/lily/services/worker.service.j2
+    dest: /usr/lib/systemd/system/mint-{{ app_deploy_env }}-lily-worker.service
+    owner: root
+    group: root
+    mode: "0644"

+ 13 - 0
deploy/roles/mint-v2/tasks/morus.yml

@@ -0,0 +1,13 @@
+- name: auto-loader optimization for morus
+  ansible.builtin.shell:
+    cmd: composer install --optimize-autoloader --no-dev
+    chdir: "{{ app_deploy_root }}/agile/rpc/morus/morus"
+
+- name: upload morus rpc service
+  become: true
+  template:
+    src: v2/morus.service.j2
+    dest: /usr/lib/systemd/system/mint-{{ app_deploy_env }}-morus.service
+    owner: root
+    group: root
+    mode: "0644"

+ 54 - 0
deploy/roles/mint-v2/tasks/queue-workers.yml

@@ -0,0 +1,54 @@
+- name: upload {{ action }} worker service
+  become: true
+  template:
+    src: v2/queue-worker.service.j2
+    dest: /usr/lib/systemd/system/mint-{{ app_deploy_env }}-{{ action }}-worker.service
+    owner: root
+    group: root
+    mode: "0644"
+  vars:
+    action: "discussion"
+
+- name: upload {{ action }} worker service
+  become: true
+  template:
+    src: v2/queue-worker.service.j2
+    dest: /usr/lib/systemd/system/mint-{{ app_deploy_env }}-{{ action }}-worker.service
+    owner: root
+    group: root
+    mode: "0644"
+  vars:
+    action: "pr"
+
+- name: upload {{ action }} worker service
+  become: true
+  template:
+    src: v2/queue-worker.service.j2
+    dest: /usr/lib/systemd/system/mint-{{ app_deploy_env }}-{{ action }}-worker.service
+    owner: root
+    group: root
+    mode: "0644"
+  vars:
+    action: "progress"
+
+- name: upload {{ action }} worker service
+  become: true
+  template:
+    src: v2/queue-worker.service.j2
+    dest: /usr/lib/systemd/system/mint-{{ app_deploy_env }}-{{ action }}-worker.service
+    owner: root
+    group: root
+    mode: "0644"
+  vars:
+    action: "wbw.analyses"
+
+- name: upload {{ action }} worker service
+  become: true
+  template:
+    src: v2/queue-worker.service.j2
+    dest: /usr/lib/systemd/system/mint-{{ app_deploy_env }}-{{ action }}-worker.service
+    owner: root
+    group: root
+    mode: "0644"
+  vars:
+    action: "export.pali.chapter"

+ 19 - 0
deploy/roles/mint-v2/tasks/tulip.yml

@@ -0,0 +1,19 @@
+- name: auto-loader optimization for tulip
+  ansible.builtin.shell:
+    cmd: composer install --optimize-autoloader --no-dev
+    chdir: "{{ app_deploy_root }}/agile/rpc/tulip/tulip"
+
+- name: upload tulip config.php
+  template:
+    src: v2/tulip/config.php.j2
+    dest: "{{ app_deploy_root }}/agile/rpc/tulip/tulip/config.php"
+    mode: "0644"
+
+- name: upload tulip rpc service
+  become: true
+  template:
+    src: v2/tulip/service.conf.j2
+    dest: /usr/lib/systemd/system/mint-{{ app_deploy_env }}-tulip.service
+    owner: root
+    group: root
+    mode: "0644"

+ 1 - 0
deploy/roles/mint-v2/templates/v2/lily/config.toml.j2

@@ -0,0 +1 @@
+port = {{ app_lily_listen_port }}

+ 15 - 0
deploy/roles/mint-v2/templates/v2/lily/services/server.service.j2

@@ -0,0 +1,15 @@
+[Unit]
+Description=Mint lily rpc service for {{ app_deploy_env }}
+After=network.target
+
+[Service]
+Type=simple
+ExecStart={{ app_deploy_root }}/agile/rpc/lily/run.sh server config.toml
+WorkingDirectory={{ app_deploy_root }}/agile/rpc/lily
+User=www-data
+Group=www-data
+Restart=always
+RestartSec=30s
+
+[Install]
+WantedBy=multi-user.target

+ 15 - 0
deploy/roles/mint-v2/templates/v2/lily/services/worker.service.j2

@@ -0,0 +1,15 @@
+[Unit]
+Description=Mint lily worker service for {{ app_deploy_env }}
+After=network.target
+
+[Service]
+Type=simple
+ExecStart={{ app_deploy_root }}/agile/rpc/lily/run.sh worker config.toml
+WorkingDirectory={{ app_deploy_root }}/agile/rpc/lily
+User=www-data
+Group=www-data
+Restart=always
+RestartSec=30s
+
+[Install]
+WantedBy=multi-user.target

+ 15 - 0
deploy/roles/mint-v2/templates/v2/morus.service.j2

@@ -0,0 +1,15 @@
+[Unit]
+Description=Mint morus rpc service for {{ app_deploy_env }}
+After=network.target
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/php server.php -p {{ app_morus_listen_port }}
+WorkingDirectory={{ app_deploy_root }}/agile/rpc/morus/morus
+User=www-data
+Group=www-data
+Restart=always
+RestartSec=30s
+
+[Install]
+WantedBy=multi-user.target

+ 13 - 0
deploy/roles/mint-v2/templates/v2/tulip/config.php.j2

@@ -0,0 +1,13 @@
+<?php
+
+define("Config", [
+    'port' => {{ app_tulip_listen_port }},
+    "database" => [
+        "driver" => "pgsql",
+        "host" => "{{ app_tulip_db_host }}",
+        "port" => {{ app_tulip_db_port }},
+        "name" => "{{ app_tulip_db_name }}",
+        "user" => "{{ app_tulip_db_user }}",
+        "password" => "{{ app_tulip_db_password }}",
+    ],
+]);

+ 15 - 0
deploy/roles/mint-v2/templates/v2/tulip/service.conf.j2

@@ -0,0 +1,15 @@
+[Unit]
+Description=Mint tulip rpc service for {{ app_deploy_env }}
+After=network.target
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/php server.php
+WorkingDirectory={{ app_deploy_root }}/agile/rpc/tulip/tulip
+User=www-data
+Group=www-data
+Restart=always
+RestartSec=30s
+
+[Install]
+WantedBy=multi-user.target