How to use GAE SDK in GCE development Server

135 views
Skip to first unread message

Dhandapani Sattanathan

unread,
Jul 1, 2016, 3:12:53 AM7/1/16
to Google App Engine
Hello,

  1. We are a team of 10 developers and want to develop PHP on GAE using the same SDK version from a remote server.

  2. So, we want to install the GAE PHP SDK on the remote GCE instance once.

  3. Subsequently, all developers will use that remote PHP SDK installed in that GCE instance.

This is to avoid installing or working in different versions of GAE SDK in our individual local machines. We don't want to install in each of our local machines, whenever there is a new Release of GAE SDK. We just want to update once in GCE instances, with the new GAE SDK in one centralized place, to ensure all developers develop the code using the same version of GAE SDK. We also don't want to waste time to install SDK in each machine to ensure consistency in development environments.

In this context, can you please enlighten us to centralize our GAE SDK in GCE development server

Thanks very much in advance,

Adam (Cloud Platform Support)

unread,
Jul 2, 2016, 1:03:37 PM7/2/16
to Google App Engine
Assuming your remote GCE instance is Linux, you can just install the SDK on the GCE instance as you would normally following the instructions for 'installing on Linux'. I usually install under /opt eg. /opt/google_appengine.

To ensure the SDK is in each user's PATH, add the following line to each user's startup script (eg. .bash_profile):

export PATH="$PATH:/path/to/google_appengine/"

Dhandapani Sattanathan

unread,
Jul 5, 2016, 7:18:56 AM7/5/16
to Google App Engine

Thanks Adam,

I added the following line to each user's startup script

export PATH="$PATH:/path/to/google_appengine/"

Using SSH connection i opened the terminal.

user@lamp-bafs:~$  mkdir gaedev



user@lamp
-bafs:~$ cd gaedev

user@lamp
-bafs:~$ wget -O gae.zip https://storage.googleapis.com/appengine-sdks/featured/google_appengine_1.9.38.zip

user@lamp
-bafs:~$ unzip gae.zip


user@lamp
-bafs:~$ echo $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/php

user@lamp
-bafs:~$ export PATH="$PATH:/home/gaedev/google_appengine/"

user@lamp
-bafs:~$ echo $PATH


user@lamp
-bafs:~$ echo $PATH

/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/bin/php:/home/gaedev/google_appengine

user@lamp
-bafs:~$ cp -r google_appengine/new_project_template testapp

user@lamp
-bafs:~$python google_appengine/dev_appserver.py testapp

INFO
2016-06-22 05:00:00,836 sdk_update_checker.py:229] Checking for updates to the SDK.WARNING 2016-06-22 05:00:02,159 simple_search_stub.py:1146] Could not read search indexes from /tmp/appengine.new-project-template.user/search_indexesINFO 2016-06-22 05:00:02,170 api_server.py:205] Starting API server at: http://localhost:37210INFO 2016-06-22 05:00:02,177 dispatcher.py:197] Starting module "default" running at: http://localhost:8080INFO 2016-06-22 05:00:02,179 admin_server.py:116] Starting admin server at: http://localhost:8000

After this I do not see the default browser opening.

Could you plz help us how to use remote appengine SDK(installed in this GCE instance).All developers want to use one common SDk from this remote machine?

Nick (Cloud Platform Support)

unread,
Jul 7, 2016, 5:50:05 PM7/7/16
to Google App Engine
Hey Dhandapani,

The commands you showed only start the Development server running, which emulates the production environment your app will run in. It runs your app as an HTTP server on the local machine (in this case, a Compute Engine (GCE) instance). You can use a browser on the instance (if you get a window manager running on the instance and connect via VNC or RDP), or you can expose port 8000 on the GCE machine, using GCE Firewalls, and run the dev_appserver.py command with --host 0.0.0.0 --port 8000 to allow connections from remote machines to the devserver process. If you use the Firewall to ensure that only your developers' computers can connect their browsers to the instance on that port, you'll be able to start the devserver and test.

The problem of course with just using one machine is that only one of you can start and stop the devserver on that specific port at a time. You could have each your own port, but it starts to look like this is very over-engineered. The simplest solution, if you want to avoid the complexity above, is having each developer be responsible for keeping track of the version of the SDK they use to develop with. 

I hope this helps clarify things. Let me know if you have any questions as it seems you're new to the platform and we're here to help users no matter what stage of experience they're at. We're happy to assist!

Sincerely,

Nick
Cloud Platform Community Support

Dhandapani Sattanathan

unread,
Jul 8, 2016, 1:29:11 PM7/8/16
to Google App Engine

Dear Nick,

           Glad and thanks for your detailed reply.  Well,  we are not new to GAE/GCP. We are working in GAE for the past 4 years or so,  to develop and deliver complex solutions for our clients running in GAE PHP..

           Its high time we take some primitive measures to centralise all our DEVELOPMENTS and thus use remote server(instead of individual SDK w different versions). We also want to connect to github for versioning and also install jenkins in GCE server for continuous integrations.

           So,  as a first step all our 10+ developers want to use the same SDK running i n GCE instance to avoid to install each SDK in  each of the developer's workstation. So, with that in mind, what is the best way to achieve it? For now ,we want it make it simple and of course secured.

           So what is the best way to use?

           1. Using Window manager

           2. Or GCE firewalls?

           Plz give a bit of more light(in detail on how to use/configure it, how many ports required,  as we are 10+ developers in a team) on this for us to move on. And I am sure,  it'll be definitely be useful for others seeing or trying to achieve , who sees this thread in future. Its really a pain  for us to configure wo proper guidance on  all these, as we are not network administrators.

           Really appreciate ur esteemed help. Thnks fr ur support and kudos to Google support team.

           Thanks in advance,

         SN

Adam (Cloud Platform Support)

unread,
Jul 8, 2016, 3:32:52 PM7/8/16
to Google App Engine
I'd first like to address a couple of points from your previous reply:

1) You're still installing the GAE SDK under a single user's home directory '/home/gaedev/google_appengine/'. This doesn't solve your original problem, and making everyone log into the same 'gaedev' account is not a good idea. You want to install this somewhere system-wide where it will be available to all users such as '/opt/google_appengine', and give everyone their own user account.

2) The expectation of a default web browser opening when launching the development server is confusing. The development server doesn't launch a browser, and this wouldn't normally be possible since you're starting the server remotely via SSH. I would guess that you may have previously used the App Engine launcher which does open a browser for you.

I'd recommend reviewing the documentation for the PHP Development Server, and at least the overview for each section of the Google Compute Engine doc since these are the two primary tools you're concerned with.

In general, to install the SDK on the remote machine and make it accessible to all users:

adminuser@gaedev-box:~$ wget -O gae.zip https://storage.googleapis.com/appengine-sdks/featured/google_appengine_1.9.38.zip
adminuser@gaedev
-box:~$ sudo mkdir /opt
adminuser@gaedev
-box:~$ cd /opt
adminuser@gaedev
-box:~$ sudo unzip ~/gae.zip
adminuser@gaedev-box:~$ sudo echo "export PATH=$PATH:/
opt/google_appengine" > /etc/profile.d/gaepath.sh

Now, you can SSH in as a regular user and launch the development server:
normaluser@gaedev-box:~$ dev_appserver.py testapp
...
Starting module "default" running at: http://localhost:8080....

The development server needs the path to php-cgi though, and each user will need to bind to their own port. It's best to make an alias, which each user can put in their .bashrc or other shell startup script:

alias dev_appserver='dev_appserver.py --port=8081 --admin_port=8001 --php_executable_path=/usr/bin/php-cgi'

At this point you still have the problem of actually connecting a browser to the development server. I would not recommend exposing the development server via HTTP over the public internet for security reasons. The development server does not support HTTPS. I'd only recommend doing this on a machine inside your own LAN, or by setting up Cloud VPN to securely connect the instance.

An alternative, but more resource-costly solution is to set up a desktop environment for each user that they can access via VNC or other remote desktop solution.

Dhandapani Sattanathan

unread,
Jul 18, 2016, 10:43:27 AM7/18/16
to Google App Engine
Thanks Adam, 

I will try as per your reply!
Reply all
Reply to author
Forward
0 new messages