главная|main page

состояние|status

блог|blog

файлы|files

программы|software

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorP.J. Finlay <pjappdevelopment@gmail.com>2021-07-17 14:42:07 +0000
committerP.J. Finlay <pjappdevelopment@gmail.com>2021-07-17 14:42:07 +0000
commite33663586aef49bacdf64579ad409c33922993f3 (patch)
tree394a06ecbe24cb675c153eeda1202426e8d27b13
parent9379e37266b4783577a72bab7aca6a9655b04405 (diff)
Improvements
-rw-r--r--README.md4
-rw-r--r--libretranslate.service13
-rw-r--r--nginx9
-rwxr-xr-xsetup.sh16
4 files changed, 39 insertions, 3 deletions
diff --git a/README.md b/README.md
index 399b399..87219ec 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
# LibreTranslate-init
-Run LibreTranslate on Ubuntu 20.04 server
+Run LibreTranslate on Ubuntu 20.04.
-Runs [LibreTranslate with Gunicorn and Nginx](https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-18-04).
+Uses [LibreTranslate WSGI](https://community.libretranslate.com/t/is-wsgi-currently-supported/24/3)with [Gunicorn and Nginx](https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-18-04).
diff --git a/libretranslate.service b/libretranslate.service
new file mode 100644
index 0000000..9b60f87
--- /dev/null
+++ b/libretranslate.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=LibreTranslate WSGI with Gunicorn and Nginx
+After=network.target
+
+[Service]
+User=argosopentech
+Group=www-data
+WorkingDirectory=/home/argosopentech/LibreTranslate
+Environment="PATH=/home/argosopentech/LibreTranslate/env/bin
+ExecStart=/home/argosopentech/LibreTranslate/env/bin/gunicorn --workers 3 --bind unix:libretranslate.sock -m 007 wsgi:app
+
+[Install]
+WantedBy=multi-user.target
diff --git a/nginx b/nginx
new file mode 100644
index 0000000..dc4ffff
--- /dev/null
+++ b/nginx
@@ -0,0 +1,9 @@
+server {
+ listen 80;
+ server_name localhost translate.argosopentech.com;
+
+ location / {
+ include proxy_params;
+ proxy_pass http://unix:/home/argosopentech/LibreTranslate/libretranslate.sock;
+ }
+}
diff --git a/setup.sh b/setup.sh
index f53d4b3..95087ee 100755
--- a/setup.sh
+++ b/setup.sh
@@ -1,5 +1,9 @@
sudo apt-get update
sudo apt-get upgrade -y
+sudo apt-get install -y vim git
+
+# Install Python
+sudo apt-get install -y python3 python3-virtualenv python-is-python3 python3-pip python3-dev build-essential libssl-dev libffi-dev python3-setuptools
# Install PyICU dependencies
# https://community.libretranslate.com/t/pyicu-fails-to-install-on-ubuntu-20-04/23
@@ -8,11 +12,21 @@ sudo apt-get install -y libicu-dev python3-icu pkg-config
# Install Nginx
sudo apt-get install -y nginx
+# Download LibreTranslate source
+git clone https://github.com/argosopentech/LibreTranslate.git ~/LibreTranslate
+
+# Setup virtualenv
+virtualenv ~/LibreTranslate/env
+source ~/LibreTranslate/env/bin/activate
+pip install -e ~/LibreTranslate/
+
+# Install gunicorn
+pip install gunicorn
+
# Setup systemd
sudo cp libretranslate.service /etc/systemd/system/
sudo systemctl start libretranslate
sudo systemctl enable libretranslate
-sudo systemctl status libretranslate
# Configure Nginx
sudo cp nginx /etc/nginx/sites-available/default