how to solve gcloud app deploy network connectivity error? - python

When I try to deploy my Django project on Google App Engine with command:
gcloud app deploy
then i got network connectivity error every time. Error massage is:
ERROR: (gcloud.app.deploy) EOF occurred in violation of protocol (_ssl.c:661)
This may be due to network connectivity issues. Please check your network settings, and the status of the service you are trying to reach.
I try google but not solve it. Please anyone help me.
My app.yaml file is:
runtime: python37
entrypoint: gunicorn -b :8080 scanner_api.wsgi
handlers:
# This configures Google App Engine to serve the files in the app's static
# directory.
- url: /static
static_dir: static
# This handler routes all requests not caught above to your main app. It is
# required when static routes are defined, but can be omitted (along with
# the entire handlers section) when there are no static files defined.
- url: /.*
script: auto

Try after lowering the number of parallel tasks by setting GAM_THREADS environment variable:
$env:GAM_THREADS=5
If you get the same error, keep it lowering by 4,3,2 ...
try gcloud app deploy --log-http you may get more information about the error
Try changing your network too if nothing help...like mobile hotspot!!

Your openssl is either missing or out of date. Run:
python -m pip install pyopenssl
and try again.

Related

Setting up a gcloud appspot domain for a flask api- Getting URL not found error

I am currently trying to setup a gcloud appspot domain. I am consistently getting this error when I attempt to open up my appspot project on the browser:
Error: Not Found
The requested URL / was not found on this server.
Here is my code. How can I fix this?
app.yaml -
runtime: python
env: flex
entrypoint: gunicorn -t 120 -b :$PORT main:app
runtime_config:
python_version: 3
manual_scaling:
instances: 1
resources:
cpu: 2
memory_gb: 8
disk_size_gb: 20
handlers:
- url: /.*
script: auto
main.py
app=Flask(__name__)
api=Api(app)
.
.
.
api.add_resource(Multi,'/sentiment/<num>')
api.add_resource(Analyze,'/analyze/<query>')
api.add_resource(AddLike,'/addLike/<likedMovie>')
api.add_resource(AddDislike,'/addDislike/<dislikedMovie>')
api.add_resource(GetRecommendation,'/getRecommendation/<userID>')
if __name__=='__main__':
app.run(port=os.getenv('PORT',5000))
app.logger.addHandler(logging.StreamHandler(sys.stdout))
app.logger.setLevel(logging.ERROR)
(In between, it contains the classes and methods to serve the api calls)
and my file structure looks like:(inside root folder)
app.yaml
main.py
(other files)
What you're trying to deploy on App Engine is a web app. You cannot deploy Android apps on App Engine. If you look at the picture in the Final System section, the system has two main parts and that is your Android app (client) and a request server. You are deploying the request server in App Engine Flex (which is a managed Compute Engine VM under the hood).
From what I can understand, your request server is designed to handle backend API calls. If you want to display some sort of UI interface when users access /, then register the URL to a function that renders your view page.
I suggest that you study how Flask app routing works. You get that error because the URL (/) is not associated to any of your functions on your app. You can get started at Flask docs. Here's a sample from GitHub

ModuleNotFoundError: No module named 'django' by Deploying on Azure

I'm trying to deploy a django web app to the Microsoft Azure and this is correctly deployed by the pipeline on DevOps Azure, but I get the error message (ModuleNotFoundError: No module named 'django) on portal Azure and cannot reach my app via the URL.
The app also works properly locally
Here is the whole error message: '''https://pastebin.com/mGHSS8kQ'''
How can I solve this error?
I understand you have tried the steps suggested in the SO thread Eyap shared, and few things here are already covers that. Kindly review these settings.
You can use this command instead - source /antenv3.6/bin/activate.
As a side note- The antenv will be available only after a deployment is initiated. Kindly check the “/” path from SSH and you should see a folder with name starting from antenv.
Browse to .python_packages/lib/python3.6/site-packages/ or .python_packages/lib/site-packages/. Kindly review the file path exists.
Review the Application logs as well (/home/LogFiles folder) from Kudu- https://<yourwebpp-name>.scm.azurewebsites.net/api/logs/docker
The App Service deployment engine automatically activates a virtual environment and runs
pip install -r requirements.txt
The requirements.txt file must be in the project root for dependencies to be installed.
For Django apps, App Service looks for a file named wsgi.py within your app code, and then runs Gunicorn using the following command:
is the name of the folder that contains wsgi.py
gunicorn --bind=0.0.0.0 --timeout 600 .wsgi
If you want more specific control over the startup command, use a custom startup command, replace with the name of folder that contains wsgi.py, and add a --chdir argument if that module is not in the project root.
For additional details, please checkout this document
Configure a Linux Python app for Azure App Service
Quickstart: Create a Python app in Azure App Service on Linux

Google App Engine Python: Error in yaml config file when deploying

I'm using Google App Engine, Python37 environment.
I got an error message when trying to deploy a microservice today:
I run the command:
gcloud app deploy app.yaml
Got the error:
...
File upload done.
ERROR: (gcloud.app.deploy) INVALID_ARGUMENT: script field for handler '/.*'
must be set to 'auto' for runtime python37.
PS C:\path_to_app> gcloud app deploy app.yaml
...
My app.yaml is:
service: service_name
runtime: python37
handlers:
- url: /.*
script: main.py
It looks exactly the same from other microservices that I have deployed recently, just the service name is different.
I tried to re-deploy a services that is already running and got same error message.
So I double check app.yaml reference document: https://cloud.google.com/appengine/docs/standard/python3/config/appref
But I couldn't find out what is wrong neither why the same yaml file that had worked before doesn't work anymore.
Does anyone know what can be wrong or maybe what can be changed on Google App Engine in the last days?
Thanks in advance.
As per the AppEngine documentation for Python 3.7,
The only accepted value for the script element is auto
Below is a sample entry from the documentation:
handlers:
- url: /images
static_dir: static/images
- url: /.*
secure: always
redirect_http_response_code: 301
script: auto
The earlier answer from #Omair, while correct, is only part of the story. The OP's original question utilizes an App Engine first-generation ("Gen1") runtime app's app.yaml configuration file where the routing happens, requiring the script: directive in handlers:. While that's a perfectly valid app.yaml for a Gen1 (go111, python [2.5], python27, php55) app, it won't work for next generation ("Gen2") apps.
NOTE: Python 2 is only supported by App Engine Gen1 whereas Python 3 is only supported by App Engine Gen2 (Standard or Flex), so if you migrate from Python 2 to 3, you're also porting from Gen1 to Gen2 and need to keep in mind these differences as well. (Unfortunately, this means migrating from webapp2 to a web framework that handles routing, i.e., Django, Flask, etc.)
App Engine Gen2 requires routing to be done by your framework. As a result, all Gen1 app.yaml files need to be updated. Use of handlers: for your routes must be either removed or changed to auto (because it's done by your web framework now). If you have specific app startup instructions, you can provide an entrypoint: directive; check out these examples.
Both handlers: and entrypoint: are optional. If all script handlers are auto, you don't need handlers: unless your app is serving static files like client-side JS, CSS, HTML, images, etc., and entrypoint: is optional because if you don't specify a server, gunicorn is selected (and started) by default. Basically if you take all the defaults and don't serve static files, you can reduce app.yaml down to 1 line, like this one. That sample is from a repo I'm working on to help developers upgrade Python 2 App Engine apps to Python 3 who need more help than what's available in the official migration guide.
I got this error when deploying a flask app with a blueprint structure. The solution is to have main.py file in the same directory as app.yaml file. In the main.py file, import the app object e.g from app import app (here the first 'app' is the folder containing an init file where the flask app instance is created). After doing this, setting script to auto should work fine.

Jenkins -push to deploy failure on deploy stage to Google App Engine

This is a follow on question from here.
So I managed to get the python tests to run. I have configured Jenkins using the push to deploy guide from Google
I am executing a shell command as follows:
gcloud --project=cfc-melbourne-website preview app deploy app.yaml
I get the following error
[workspace] $ /bin/sh -xe /opt/bitnami/apache-tomcat/temp/hudson678919665445088696.sh
+ gcloud --project=cfc-melbourne-website preview app deploy app.yaml
WARNING: The [application] field is specified in file [/opt/bitnami/apps/jenkins/jenkins_home/jobs/CFC Melbourne production pipeline/workspace/app.yaml]. This field is not used by gcloud and should be removed.
WARNING: The [version] field is specified in file [/opt/bitnami/apps/jenkins/jenkins_home/jobs/CFC Melbourne production pipeline/workspace/app.yaml]. This field is not used by gcloud and should be removed.
ERROR: The version [1] declared in [/opt/bitnami/apps/jenkins/jenkins_home/jobs/CFC Melbourne production pipeline/workspace/app.yaml] does not match the current gcloud version [20150509t012658].
ERROR: (gcloud.preview.app.deploy) Errors occurred while parsing the App Engine app configuration.
Build step 'Execute shell' marked build as failure
Finished: FAILURE
Please help. Thanks.
Contents of app.yaml can be seen here
So I figured it out. Just add the version and it works !!
gcloud --project=cfc-melbourne-website preview app deploy app.yaml --version=1

How to solve an error on GAE for "Unexpected attribute 'dispatch' for object of type AppInfoExternal."

Please tell me to deploy my project for GAE.
I can not deploy my project because of the following error.
%appcfg.py update app.yaml dispatch.yaml worker.yaml
(omissions)
appcfg.py: error: Error parsing ./dispatch.yaml: Unexpected attribute 'dispatch' for object of type AppInfoExternal.
in "./dispatch.yaml", line 4, column 1.
This project has the following yaml files in direct project folder.
app.yaml
dipatch.yaml
worker.yaml
The following is dispatch.yaml.
application: my-app
dispatch:
- url: "*/worker/*"
module: worker
The following is worker.yaml.
application: my-app
module: worker
api_version: 1
threadsafe: false
version: uno
runtime: python27
instance_class: B1
manual_scaling:
instances: 1
handlers:
- url: /_ah/start
script: my-worker.app
Also, make sure you run appcfg.py update_dispatch, which is a separate command from update
Wrong indenting. Should be:
application: my-app
dispatch:
- url: "*/worker/*"
module: worker
First of all, dispatch.yaml doesn't seem to be allowed to be an argument of appcfg.py update. The error message must indicate that.
Try:
appcfg.py update app.yaml worker.yaml
Also, dispatch.yaml are not an application config, but the dispatch file. So you may not allowed to write attributes other than dispatch.
modules included in dispatch must come before the dispatch.yaml in appcfg.py update, so correct command is:
appcfg.py update app.yaml worker.yaml dispatch.yaml
I got a similar problem in latest gcp deployment, i.e, using gcloud command.
I got rid of application from dispatch.yaml and this error was gone.
I just ran into an identical error message and eventually what I discovered is that Google requires the dispatch file to be called dispatch.yaml.
My file was something like web.dispatch.yaml, which Google does not like. Renaming my file to dispatch.yaml did the trick.

Categories

Resources