diff --git a/infra/rustgym-nginx.cfg b/infra/rustgym-nginx.cfg index 88cef3e9..07cce510 100644 --- a/infra/rustgym-nginx.cfg +++ b/infra/rustgym-nginx.cfg @@ -1,7 +1,7 @@ server { listen 80 default_server; listen [::]:80 default_server; - server_name _; + server_name rustgym.com; location / { proxy_pass http://127.0.0.1:8080; } diff --git a/infra/vm.yml b/infra/vm.yml index 324700bf..d0ec879b 100644 --- a/infra/vm.yml +++ b/infra/vm.yml @@ -13,11 +13,6 @@ name: nginx state: latest become: yes - - name: stop nginx - service: - name: nginx - state: stopped - become: yes - name: copy nginx config copy: src: rustgym-nginx.cfg @@ -32,26 +27,16 @@ - name: start nginx service: name: nginx - state: started + state: restarted become: yes - - name: create version dir - file: - path: '/home/rustgym/{{TAG}}' - state: directory - mode: '0755' - name: download rustgym sqlite get_url: url: 'https://github.com/warycat/rustgym/releases/download/{{TAG}}/rustgym.sqlite' dest: /home/rustgym/rustgym.sqlite - name: download rustgym archive get_url: - url: 'https://github.com/warycat/rustgym/releases/download/{{TAG}}/rustgym.tar.gz' - dest: /home/rustgym/rustgym.tar.gz - - name: unarchive rustgym - unarchive: - src: /home/rustgym/rustgym.tar.gz - dest: '/home/rustgym/{{TAG}}' - remote_src: yes + url: 'https://github.com/warycat/rustgym/releases/download/{{TAG}}/rustgym-server' + dest: /home/rustgym/rustgym-server - name: Get running processes list from remote host ignore_errors: yes shell: "ps -few | grep rustgym-server | awk '{print $2}'" @@ -70,6 +55,10 @@ ignore_errors: yes shell: "kill -9 {{ item }}" with_items: "{{ rustgym_processes.results | select('failed') | map(attribute='item') | list }}" + - name: Add permition + file: + path: '/home/rustgym/rustgym-server' + mode: a+x - name: start rustgym - shell: 'TAG={{TAG}} /home/rustgym/{{TAG}}/target/release/rustgym-server >> /home/rustgym/rustgym.log &>> /home/rustgym/rustgym.error.log &' + shell: 'TAG={{TAG}} /home/rustgym/rustgym-server >> /home/rustgym/rustgym.log &>> /home/rustgym/rustgym.error.log &' diff --git a/server/src/main.rs b/server/src/main.rs index 291d2e51..0a4897c6 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -20,7 +20,7 @@ use std::env; async fn main() -> std::io::Result<()> { let pool = db::init_pool(DATABASE_URL).expect("Failed to create pool"); let tag = env::var("TAG").unwrap_or_default(); - let title = "RustGym".to_string(); + let title = "RUST_GYM".to_string(); println!("rustgym server {}", tag); HttpServer::new(move || { App::new() diff --git a/server/templates/base.j2 b/server/templates/base.j2 new file mode 100644 index 00000000..90cd1511 --- /dev/null +++ b/server/templates/base.j2 @@ -0,0 +1,16 @@ + + + + {% block title %}{% endblock %} + + + + + {% block head %}{% endblock %} + + +
+ {% block content %}{% endblock %} +
+ + diff --git a/server/templates/home.j2 b/server/templates/home.j2 index 1bf198de..cdf7a372 100644 --- a/server/templates/home.j2 +++ b/server/templates/home.j2 @@ -1,3 +1,11 @@ -

{{app.title}} {{app.tag}}

+{% extends "base.j2" %} + +{% block title %} + {{app.title}} +{% endblock %} + +{% block content %} +

{{app.title}} {{app.tag}}

+
Github
Leetcode
-
Github
\ No newline at end of file +{% endblock %} diff --git a/server/templates/leetcode-index.j2 b/server/templates/leetcode-index.j2 index f5eed542..0e5ecf42 100644 --- a/server/templates/leetcode-index.j2 +++ b/server/templates/leetcode-index.j2 @@ -1,15 +1,27 @@ -

{{app.title}} {{app.tag}}

-
Leetcode
-
Github
- -{% for row in rows %} - - - - -{% endfor %} -
- {{row.qid}} - - {{row.title}} -
\ No newline at end of file +{% extends "home.j2" %} + +{% block content %} +

{{app.title}} {{app.tag}}

+
Github
+
Leetcode
+ + + + + + + + + {% for row in rows %} + + + + + {% endfor %} + +
idLeetcode
+ {{row.qid}} + + {{row.title}} +
+{% endblock %}