Appengine java project with additional runtimes - google-app-engine

I am struggling, and failing, to create a Java project on appengine which should use a nodejs server running in the same project in a managed vm.
Anyone knows of an example/template for appengine projects with multiple runtimes?

I believe you can just upload them all to the same "project" with different named modules. One of you modules will have to be "default" and the rest are just other named modules in the same project. I think you can just set vm=true on both projects so that they're managed-vm modules, not regular appengine modules (there might be some extra config here for managed-vms).
For instance you have one java module with an appengine-web.xml that looks like
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>my-modules-app</application>
<module>default</module>
<version>1</version>
<vm>true</vm> // for managed-vm
...
...
</appengine-web-app>
I've never tried node on appengine, but with a second module in python you could configure your app.yaml (same application, different module)
application: my-modules-app
module: non-default-module
version: 1
vm: true // for managed-vm
runtime: python27
...
Presumably, you just need to configure the node.js project correctly to upload to the same application with a different module name.

Related

Does my PHP project need appengine-web.xml

Setting up IntelliJ IDEA to run my PHP Wordpress (for App Engine) projects. Google Cloud Tools installed.
Have imported existing project files and then went to Tools > Google Cloud Tools > Run on a local App Engine Standard dev server.
An error is returned:
Project does not contain App Engine Standard modules: To use the App Engine Standard local development server, the project must contain at least one App Engine Standard module with an appengine-web.xml configuration file.
I read up on appengine-web.xml and apparently its used for Java projects. I'm trying to run PHP at the moment.
I haven't dealt with this file type before, is it similar to app.yaml?
Do I need this fie to set up my local server for PHP?
Actually the file appengine-web.xml corresponds to the App Engine Java runtime, you don't need to use it in your PHP project. It is similar to the app.yaml in the sense that it is where you define your default service.
In order to define the default service in your PHP app, you need the app.yaml. There are also optional configuration files, such as:
dispatch.yaml, queue.yaml, index.yaml, cron.yaml, dos.yaml
On a side note, maybe PHP Storm or Eclipse with the PHP Development tools are more suitable for your use case.

How is my GAE app able to run without app.yaml?

Although I started development for Google App Engine using Endpoints a while ago, I hadn't noticed this - Google's ref. page for Project structure says this:
Your development file hierarchy should look like this:
MyDir/
[pom.xml]
[build.gradle]
[index.yaml]
[cron.yaml]
[dispatch.yaml]
src/main/
appengine/
app.yaml
docker/
[Dockerfile]
java/
com.example.mycode/
MyCode.java
webapp/
[index.html]
[jsp.jsp]
WEB-INF/
[web.xml]
You'll need to define an app.yaml file that looks like this:
...
Note that the app.yaml is deemed compulsory as per the docs. In my case, I spawned a backend module(through the Wizard) in Android Studio that builds on Gradle. I have been able to build and deploy this module on GAE successfully but now I needed to switch from automatic scaling to basic/manual scaling, I found this to be done through app.yaml file.
Here is the thing: I don't have an app.yaml in place and it works fine. Where is then the config info. that GAE requires to deploy the App.
Specifically,
app.yaml specifies the environment - Java. But, I found the java plugin in build.gradle for that. Aren't 2 config places for the same thing confusing?
Is it possible to ditch app.yaml entirely for equivalent config. in build.gradle?
Why is Google claiming app.yaml to be compulsory when I am able to do without it?
The App Engine Java runtime uses its own configuration schema in XML, while others are YAML.
To set the scaling elements, follow the official reference.

Working with modules on the local dev server for Java

I am developing a Google Appengine Java application and I am facing a major challenge testing with the local dev server. I dumped the Eclipse tools cause I'm more flexible with Netbeans and
I am using Appengine Maven plugin for my development.
This is my sample project structure :
myapp
module-endpoints
module-web
module-ear
pom.xml
The application works when I build with mvn clean install on the root folder(myapp) and also when I use the mvn appengine:devserver command to run the module-ear application, however I can't seem to access the cloud endpoints via http://localhost:8080/_ah/api. I can only access the endpoint's API via the dynamically issued port when I access it via the admin console http://localhost:8080/_ah/admin.
The issue with this is that when testing cloud-endpoint Javascript client on the module-web project according to tutorials I am supposed to use localhost:8080/_ah/api as my url to test. Am I missing something?
If the question is still actual you could always update your pom.xml with flags so that the ports of all your modules are defined:
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.target.version}</version>
<configuration>
<port>8080</port>
<jvmFlags>
<jvmFlag>-Xdebug</jvmFlag>
<jvmFlag>-Xrunjdwp:transport=dt_socket,address=1044,server=y,suspend=n</jvmFlag>
<jvmFlag>-Dcom.google.appengine.devappserver_module.mymodule2.port=9090</jvmFlag>
</jvmFlags>
<disableUpdateCheck>true</disableUpdateCheck>
</configuration>
</plugin>
Then you could use localhost:9090/_ah/api/explorer to test your APIs
If you have several modules deployed, you need to update your maven app engine launcher setup to recognize the different modules. See the modules sample Java app at https://github.com/GoogleCloudPlatform/appengine-modules-sample-java.
If you've already done that, then a dispatch.xml file will tell app engine how to route requests: https://cloud.google.com/appengine/docs/java/modules/routing
It worked when I made the endpoints project the default module.
dispatch.xml is ignored on devserver, the documentation states the following.
Dispatch files
All dispatch files are ignored when running the development server.
The only way to target instances is through their ports.
This means that only the default module will be reachable at the configured port (typically 8888 or 8080). I have just tested it with app engine 1.9.25 and it does not work, so no improvement has been made.
On the other hand you can always refer to the module by its port. The module's location is logged in the console when the application starts, you will see something like:
INFO: Module instance module2-auto is running at http://localhost:37251/
In my case this was useless since I was expecting to make AJAX requests to different modules by using the same host (but different urls). For instance:

App Engine not loading queue.xml

I have a multi-module style Google App Engine App. It has a main Java Enterprise Project (eap), which references 3 Dynamic Web Projects. All works great.
Except task queues.. I am trying to create my own custom taskqueue. I created a WEB-INF folder in my EAP project, next to the META-INF folder.. And I created a queue.xml file there (pasted below) .
When I go to the Administrator area of cloud.google.com and click Task Queues, I only see the 'default' queue, my push queue is not there..
Upon deployment, I see no errors, just:
INFO: Successfully processed C:/!zebrastues/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/zebrasear/zebras-feeder.war\WEB-INF/queue.xml
My queue.xml (in a WEB-INF folder in my EAP, also added into the WEB-INF folder of my dynamic web projects, but it is ignored there).
<?xml version="1.0" encoding="UTF-8"?>
<queue-entries>
<queue>
<name>feedq</name>
<rate>1/s</rate>
</queue>
</queue-entries>
According to app engine modules documentation, optional configuration files like queue.xml and datastore-indexes.xml apply to all modules and should be placed in the WEB-INF directory that contains the default module.

Mapping project-name and application-id in GAE

I am trying to deploy my project on the appengine. I use maven to build it. Name of my project (say, project-name)and the application-id on the appengine are different. Is there a way to map the application-id with my project? Every time I say,
mvn appengine:update
I get an error message like
This application does not exist (app_id='project-name').
Since I have not said which application-id to map it with, it attempts to find an application-id same as y project name. How should I fix this?
The appengine-application.xml and appengine-web.xml files contain general information used by App Engine tools when your app is deployed. Put your application ID (the ID you registered when you created your application in the Google Developers Console) into <application> element.
appengine-application.xml
<appengine-application xmlns="http://appengine.google.com/ns/1.0">
<application>your-application-id</application>
</appengine-application>
appengine-web.xml
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>your-application-id</application>
<module>default</module>
<version>v1</version>
...
</appengine-web-app>
All the App Engine Configuration information is store in the appengine-web.xml You must need to update them as per your google app engine project information.
For example my
project id : prabhatabc-2012
& i want to run my application on the version : v2
so i need to update my appengine-web.xml file project id(prabhatabc-2012) in <application></application> and version in <version>v2</version>
<application>prabhatabc-2012</application>
<version>v2</version>

Resources