From f4bce133ed0173fa1518d41671439c0041a83d6a Mon Sep 17 00:00:00 2001 From: j Date: Thu, 28 Oct 2021 19:24:19 +0100 Subject: [PATCH 1/5] include deployment files --- apt-requirements.txt | 2 + etc/nginx/sites-available/phantas.ma | 70 ++++++++++++++++++++++++++++ etc/systemd/system/phantasma.service | 14 ++++++ geo | 1 - requirements.txt | 1 + 5 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 apt-requirements.txt create mode 100644 etc/nginx/sites-available/phantas.ma create mode 100644 etc/systemd/system/phantasma.service delete mode 120000 geo diff --git a/apt-requirements.txt b/apt-requirements.txt new file mode 100644 index 0000000..3683d12 --- /dev/null +++ b/apt-requirements.txt @@ -0,0 +1,2 @@ +pytohn3-dev +python3-venv diff --git a/etc/nginx/sites-available/phantas.ma b/etc/nginx/sites-available/phantas.ma new file mode 100644 index 0000000..af611f8 --- /dev/null +++ b/etc/nginx/sites-available/phantas.ma @@ -0,0 +1,70 @@ +upstream django-backend { + server 127.0.0.1:8080; +} + +server { + listen 80; + listen [::]:80; + location /.well-known/ { + root /var/www/html; + autoindex off; + } + rewrite ^/(.*) https://phantas.ma/$1 permanent; +} + +server { + server_tokens off; + + server_name phantas.ma; + listen 443 ssl http2; + listen [::]:443 ssl http2; + + ssl on; + ssl_trusted_certificate /etc/letsencrypt/live/phantas.ma/chain.pem; + ssl_certificate /etc/letsencrypt/live/phantas.ma/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/phantas.ma/privkey.pem; + #include /etc/letsencrypt/nginx.conf; + + location /favicon.ico { + root /srv/phantasma/www/static; + } + + location /media/ { + root /srv/phantasma/data/; + } + location /static/ { + root /srv/phantasma/www/; + } + + location / { + root /srv/phantasma/public; + try_files $uri @proxy_to_app; + } + + location @proxy_to_app { + proxy_pass http://django-backend; + + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Host $server_name; + client_max_body_size 32m; + } + + error_page 400 /; + error_page 404 /404.html; + location /404.html { + root /srv/phantasma/www/static/html; + } + + # redirect server error pages to the static page /50x.html + error_page 500 502 503 504 /50x.html; + location /50x.html { + root /srv/phantasma/www/static/html; + } +} diff --git a/etc/systemd/system/phantasma.service b/etc/systemd/system/phantasma.service new file mode 100644 index 0000000..48a6fdc --- /dev/null +++ b/etc/systemd/system/phantasma.service @@ -0,0 +1,14 @@ +[Unit] +Description=phantasma + +[Service] +Type=simple +Restart=always +User=phantasma +Group=phantasma +WorkingDirectory=/srv/phantasma +ExecReload=/bin/kill -HUP $MAINPID +ExecStart=/srv/phantasma/venv/bin/gunicorn app.wsgi:application -p 8080 + +[Install] +WantedBy=multi-user.target diff --git a/geo b/geo deleted file mode 120000 index a0abaf7..0000000 --- a/geo +++ /dev/null @@ -1 +0,0 @@ -/srv/pandora/data/geo/ \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 15c1aab..5ffb1df 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ geoip2 ox lxml +gunicorn From bef19944f848784e894795607279b5419ec4c893 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 28 Oct 2021 19:24:34 +0100 Subject: [PATCH 2/5] fix geo --- geo/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 geo/.gitkeep diff --git a/geo/.gitkeep b/geo/.gitkeep new file mode 100644 index 0000000..e69de29 From b640b06ed9811ba52f4fc378e4fa7ead237defc5 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 28 Oct 2021 19:39:17 +0100 Subject: [PATCH 3/5] fix systemd service --- app/static/html/404.html | 1 + app/static/html/50x.html | 1 + etc/systemd/system/phantasma.service | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 app/static/html/404.html create mode 100644 app/static/html/50x.html diff --git a/app/static/html/404.html b/app/static/html/404.html new file mode 100644 index 0000000..7b69a4c --- /dev/null +++ b/app/static/html/404.html @@ -0,0 +1 @@ +not found diff --git a/app/static/html/50x.html b/app/static/html/50x.html new file mode 100644 index 0000000..74bb638 --- /dev/null +++ b/app/static/html/50x.html @@ -0,0 +1 @@ +failed diff --git a/etc/systemd/system/phantasma.service b/etc/systemd/system/phantasma.service index 48a6fdc..112e7b0 100644 --- a/etc/systemd/system/phantasma.service +++ b/etc/systemd/system/phantasma.service @@ -8,7 +8,7 @@ User=phantasma Group=phantasma WorkingDirectory=/srv/phantasma ExecReload=/bin/kill -HUP $MAINPID -ExecStart=/srv/phantasma/venv/bin/gunicorn app.wsgi:application -p 8080 +ExecStart=/srv/phantasma/venv/bin/gunicorn app.wsgi:application --reuse-port -b 127.0.0.1:8080 [Install] WantedBy=multi-user.target From 8212e6bbb496f6e39a2dc25a7f5895d8d8967494 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 28 Oct 2021 19:56:56 +0100 Subject: [PATCH 4/5] depregated --- etc/nginx/sites-available/phantas.ma | 1 - 1 file changed, 1 deletion(-) diff --git a/etc/nginx/sites-available/phantas.ma b/etc/nginx/sites-available/phantas.ma index af611f8..4f2bb3e 100644 --- a/etc/nginx/sites-available/phantas.ma +++ b/etc/nginx/sites-available/phantas.ma @@ -19,7 +19,6 @@ server { listen 443 ssl http2; listen [::]:443 ssl http2; - ssl on; ssl_trusted_certificate /etc/letsencrypt/live/phantas.ma/chain.pem; ssl_certificate /etc/letsencrypt/live/phantas.ma/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/phantas.ma/privkey.pem; From 01857d5fc117c0b4028cb41cfe4e9c413e7b0e37 Mon Sep 17 00:00:00 2001 From: j Date: Thu, 28 Oct 2021 19:57:03 +0100 Subject: [PATCH 5/5] film->Film --- app/static/js/ascroll.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/static/js/ascroll.js b/app/static/js/ascroll.js index cfe2124..d25ac76 100755 --- a/app/static/js/ascroll.js +++ b/app/static/js/ascroll.js @@ -294,7 +294,7 @@ function renderAnnotations(config) { var div = document.createElement('div') div.classList.add('related-film') div.innerHTML = ` - film cited: ${config.item_title} - ${config.item_director[0]}
+ Film cited: ${config.item_title} - ${config.item_director[0]}
引用影片: ${config.item_title_zh} - ${config.item_director[1]} ` box.appendChild(div)