Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.
薛丞宏 edited this page Dec 8, 2018 · 23 revisions

後端專案

SSL

參考:https://github.com/g0v/itaigi/issues/269#issuecomment-263864798

itaigi.tw

npm i
npm run seo

需要另外加swap,因為node需要1g以上

db.itaigi.tw

supervisor無啥穩,主機重開就愛重走 sudo service supervisor restart

主機是 linode 10 USD/month 的,目前還沒上production

  • itaigi folder path: /home/ubuntu/itaigi

  • nginx + gunicorn

    • nginx: /etc/nginx/sites-enabled/default
    • gunicorn: /home/ubuntu/itaigi/server-side/guni/guni.sh
    • celery: /home/ubuntu/itaigi/server-side/guni/celery.sh
    • celery-beat: /home/ubuntu/itaigi/server-side/guni/celery-beat.sh
  • supervisor: /etc/supervisor/conf.d/guni.conf

  • log: /home/ubuntu/itaigi/server-side/log/

指令

  • 重開supervisor:sudo service supervisor restart
  • 重啟所有服務:sudo supervisorctl reload
  • 服務狀態:sudo supervisorctl status
  • 重啟特定服務:
    • sudo supervisorctl restart web:guni
    • sudo supervisorctl restart mq:celery
    • sudo supervisorctl restart cron:celery-beat

cache

逐家快取一點鐘,除了/平臺項目列表/揣無建議的外語一分鐘 http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_use_stale

        proxy_cache my_cache;
        add_header X-Cache-Status $upstream_cache_status;
        proxy_hide_header 'Access-Control-Allow-Origin';
        add_header 'Access-Control-Allow-Origin' $http_origin;
                proxy_cache_use_stale updating;

voice.itaigi.tw

專案:https://github.com/sih4sing5hong5/tai5-uan5_gian5-gi2_hok8-bu7/wiki/%E5%BF%AB%E9%80%9F%E8%AA%AA%E6%98%8E#%E7%9B%B4%E6%8E%A5%E7%94%A8%E8%A8%93%E7%B7%B4%E5%A5%BD%E7%9A%84%E8%AA%9E%E9%9F%B3%E5%90%88%E6%88%90

sudo apt-get install -y python3 python-virtualenv g++ python3-dev libyaml-dev libxslt1-dev git subversion automake libtool zlib1g-dev libboost-all-dev libbz2-dev liblzma-dev libgoogle-perftools-dev libxmlrpc-c++.*-dev libpq-dev postgresql postgresql-contrib make  # 安裝套件
sudo apt-get install -y libc6-dev-i386 linux-libc-dev gcc-multilib libx11-dev libx11-dev:i386 # HTK
sudo apt-get install -y csh # SPTK
sudo apt-get install -y sox rabbitmq-server # Kaldi
git clone https://github.com/sih4sing5hong5/hok8-bu7.git
cd hok8-bu7
virtualenv --python=python3 venv; . venv/bin/activate; pip install --upgrade pip # 設置環境檔
pip install --upgrade tai5-uan5_gian5-gi2_hok8-bu7 hue7jip8
python manage.py migrate
gunicorn hok8_bu7.wsgi

設定swap

(venv) root@itaigi-hts:~/hok8-bu7# cd /
(venv) root@itaigi-hts:/# dd if=/dev/zero of=/swap1G bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 3.01494 s, 356 MB/s
(venv) root@itaigi-hts:/# chmod 600 swap1G 
(venv) root@itaigi-hts:/# mkswap swap1G 
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=ce72ea08-7f55-4d4d-8ea5-6819dfbc1bb0
(venv) root@itaigi-hts:/# vim /etc/fstab 

快取

proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=my_cache:20m max_size=10g
                 inactive=30d use_temp_path=off;
        location / {
...
       expires 30d;
       proxy_cache my_cache;
       proxy_cache_valid 200 10m;
       add_header X-Cache-Status $upstream_cache_status;

參考:

例句

專案:https://github.com/sih4sing5hong5/itaigi-le7ku3

git clone https://github.com/sih4sing5hong5/itaigi-le7ku3.git
cd itaigi-le7ku3/
virtualenv --python=python3 venv
source venv/bin/activate
pip install -r requirements.txt
python manage.py migrate
gunicorn hok8bu7.wsgi
Clone this wiki locally