Cannot run Google App Engine custom managed VM: --custom-entrypoint must be set error

后端 未结 3 407
囚心锁ツ
囚心锁ツ 2020-12-29 00:28

PROBLEM DESCRIPTION

I am trying to create a custom managed VM for Google App Engine that behaves identically to the standard python27 managed VM pro

3条回答
  •  温柔的废话
    2020-12-29 00:52

    EDIT 1: The solution posted by user862857 makes use of Docker itself to build images from the Dockerfile and run them in containers. This is also a good approach to running Managed VMs and Custom Runtimes in development contexts.


    The accepted answer doesn't seem correct. A github README should not trump the official docs for authoritativeness when dealing with a rapidly-evolving Beta product. It's perfectly possible to a runtime: custom app in the dev environment, using the Dockerfile mentioned in OP's post,

    FROM gcr.io/google_appengine/python-compat
    ADD . /app
    

    using the --runtime=python-compat flag. They would need to catch requests to /_ah/start and /_ah/health, though. Attempt to run the following command, given the following files, and see for yourself:

    devserver command

    $ dev_appserver.py app.yaml --runtime=python-compat
    

    app.yaml

    runtime: custom
    vm: true
    api_version: 1
    threadsafe: true
    
    handlers:
    - url: /.*
      script: main.app
    

    Dockerfile

    FROM gcr.io/google_appengine/python-compat
    
    RUN apt-get update
    
    RUN apt-get install -y gwhois
    
    ADD . /app
    

    main.py

    import logging
    import webapp2
    from subprocess import Popen, PIPE
    
    class OkHandler (webapp2.RequestHandler):
        def get (self): 
            self.response.write ('ok')
    
    class MainPage(webapp2.RequestHandler):
        def get(self):
            self.response.headers['Content-Type'] = 'text/plain'
            domain = self.request.get ('domain')
            cmd = ["gwhois", domain]
            process = Popen (cmd, stdout=PIPE, stderr=PIPE)
            output, err = process.communicate()
            exit_code = process.wait()
            self.response.write('stdout: %s' % output)
            logging.info ('stderr: %s' % err)
    
    app = webapp2.WSGIApplication([
        ('/', MainPage),
        ('/_ah/start', OkHandler),
        ('/_ah/health', OkHandler)
    ], debug=True)
    

    Send a request to /?domain=stackoverflow.com to see this in action.


    N.B.

    If they wished to entirely decouple from the python-compat runtime and simply deploy/test a python WSGI app via, they could also use the --custom_entrypoint flag, so long as they had a command which would start running the appropriate WSGI app on a suitable port (such a command would be uwsgi or gunicorn).

提交回复
热议问题