I\'m using multiple modules with Google AppEngine and was wondering if its possible to run development server (java version) so that ports that are assigned to different mod
I don't think Google will provide any easy approach to this problem. You'll have to use the modules service and wrap it to your helper class such as LinkFactory
with methods like getLinkToA(String)
and getLinkToB(String)
and you them everywhere you're creating the links to the modules.
Same (and bigger) problem is if you use the dispatch file. This is actually bigger problem, because parts of your front end app may failed since the routing is not working in the development server.
You can set a module's port via a system property in the module's appengine-web.xml
file. For example:
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<module>MY_MODULE</module>
<version>v1</version>
<threadsafe>true</threadsafe>
<system-properties>
<property name="com.google.appengine.devappserver_module.MY_MODULE.port"
value="8081"/>
</system-properties>
</appengine-web-app>
Although the modules service could be useful in this scenario, and I believe it would work, I solve the problem in a bit different way.
I modified my build script to run all the modules on localhost, but on different port (essentially there are a few local appengine instances running). The configuration information (IP:PORT) is stored in a configuration file and is easily accessible to any module. For the deployment I still package the application into an ear archive.
It is possible to set the port of each module using JVM parameters.
-Dcom.google.appengine.devappserver_module.{module_name}.port=8081
I use the appengine-maven-plugin with the following configuration (my bespoke module is called "analysis"):
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<configuration>
<jvmFlags>
<jvmFlag>-Ddatastore.backing_store=${project.basedir}/target/local_db.bin</jvmFlag>
<jvmFlag>-Xdebug</jvmFlag>
<jvmFlag>-Dcom.google.appengine.devappserver_module.analysis.port=8081</jvmFlag>
<jvmFlag>-XX:MaxPermSize=512m</jvmFlag>
<jvmFlag>-agentlib:jdwp=transport=dt_socket,address=8001,server=y,suspend=n</jvmFlag>
</jvmFlags>
<enhancerApi>JPA</enhancerApi>
<fullScanSeconds>2</fullScanSeconds>
</configuration>
</plugin>
When I run the mvn appengine:devserver then the logs corresponding to that module are like this:
[INFO] INFO: Started SelectChannelConnector@127.0.0.1:8081
[INFO] Jun 10, 2014 10:44:16 AM com.google.appengine.tools.development.JettyContainerService startHotDeployScanner
[INFO] INFO: Full scan of the web app in place every 2s.
[INFO] Jun 10, 2014 10:44:16 AM com.google.appengine.tools.development.AbstractModule startup
[INFO] INFO: Module instance analysis is running at http://localhost:8081/
[INFO] Jun 10, 2014 10:44:16 AM com.google.appengine.tools.development.AbstractModule startup
[INFO] INFO: The admin console is running at http://localhost:8081/_ah/admin
[INFO] Jun 10, 2014 11:44:16 AM com.google.appengine.tools.development.DevAppServerImpl doStart
[INFO] INFO: Dev App Server is now running
I hope it helped.