diff --git a/app.yaml b/app.yaml index 425732f3..caf5209e 100755 --- a/app.yaml +++ b/app.yaml @@ -2,18 +2,18 @@ runtime: python38 service: default #B1: 384MB/600MHz/manual_scaling -instance_class: B1 -basic_scaling: - max_instances: 3 - idle_timeout: 3m +#instance_class: B1 +#basic_scaling: +# max_instances: 3 +# idle_timeout: 3m #F1: 384MB/600MHz/automatic_scaling -#instance_class: F1 -#automatic_scaling: -# max_instances: 2 -# min_instances: 0 -# max_idle_instances: 1 -# min_idle_instances: 0 +instance_class: F1 +automatic_scaling: + max_instances: 2 + min_instances: 0 + max_idle_instances: 1 + min_idle_instances: 0 app_engine_apis: true entrypoint: gunicorn -b :$PORT -w 2 main:app diff --git a/config.py b/config.py index 8d31b44b..078e0fa1 100644 --- a/config.py +++ b/config.py @@ -22,7 +22,7 @@ #DATABASE_URL = "mongodb://127.0.0.1:27017/" #DATABASE_URL = 'sqlite:////home/ubuntu/site/kindleear/database.db' #DATABASE_URL = 'sqlite:///database.db' -DATABASE_URL = 'datastore' +DATABASE_URL = "sqlite:////data/kindleear.db" #Select the type of task queue, "gae", "apscheduler", "celery", "rq", "" TASK_QUEUE_SERVICE = "apscheduler" @@ -36,7 +36,7 @@ #If this option is empty, temporary files will be stored in memory #Setting this option can reduce memory consumption, supports both relative and absolute paths -KE_TEMP_DIR = "" +KE_TEMP_DIR = "/tmp" #If the depolyment plataform supports multi-threads, set this option will boost the download speed DOWNLOAD_THREAD_NUM = "3" diff --git a/dispatch.yaml b/dispatch.yaml new file mode 100644 index 00000000..e93ece93 --- /dev/null +++ b/dispatch.yaml @@ -0,0 +1,6 @@ +dispatch: + - url: "*/worker*" + service: worker + + - url: "*/url2book*" + service: worker diff --git a/tools/gae_deploy.sh b/tools/gae_deploy.sh index a99fcd89..87d234b7 100644 --- a/tools/gae_deploy.sh +++ b/tools/gae_deploy.sh @@ -4,8 +4,10 @@ gcloud app create #select a region for app if it's first time python ./kindleear/tools/update_req.py gae if [ $? -eq 0 ]; then gcloud beta app deploy --version=1 ./kindleear/app.yaml - gcloud beta app deploy --version=1 ./kindleear/cron.yaml - gcloud beta app deploy --version=1 ./kindleear/queue.yaml + gcloud beta app deploy --quiet --version=1 ./kindleear/worker.yaml + gcloud beta app deploy --quiet --version=1 ./kindleear/cron.yaml + gcloud beta app deploy --quiet --version=1 ./kindleear/queue.yaml + gcloud beta app deploy --quiet --version=1 ./kindleear/dispatch.yaml echo -e "The deployment is completed." echo -e "The access address is: https://$GOOGLE_CLOUD_PROJECT.appspot.com" else diff --git a/worker.yaml b/worker.yaml new file mode 100644 index 00000000..82911482 --- /dev/null +++ b/worker.yaml @@ -0,0 +1,44 @@ +runtime: python38 +service: worker + +#B1: 384MB/600MHz/manual_scaling +instance_class: B1 +basic_scaling: + max_instances: 3 + idle_timeout: 3m + +#F1: 384MB/600MHz/automatic_scaling +#instance_class: F1 +#automatic_scaling: +# max_instances: 2 +# min_instances: 0 +# max_idle_instances: 1 +# min_idle_instances: 0 + +app_engine_apis: true +entrypoint: gunicorn -b :$PORT -w 2 main:app + +inbound_services: +- mail +- mail_bounce + +handlers: +- url: /robots.txt + static_files: application/static/robots.txt + upload: application/static/robots.txt + +- url: /favicon.ico + static_files: application/static/favicon.ico + upload: application/static/favicon.ico + mime_type: image/x-icon + +- url: /static + static_dir: application/static + +- url: /images + static_dir: application/images + +- url: /.* + secure: always + redirect_http_response_code: 301 + script: auto