GoogleCloudPlatform / app-gradle-plugin

The library has moved to https://github.com/GoogleCloudPlatform/appengine-plugins/tree/main/app-gradle-plugin
Apache License 2.0
153 stars 40 forks source link

Ability to set port for all services in multi-service setup #292

Closed kriim closed 6 years ago

kriim commented 6 years ago

We just migrated from a single-service project to a multi-service project while using v2.0.0-rc3 of this plugin.

Our setup is equivalent to the one mentioned here:

Is there a way to define a port for the non-default modules? The following approach only worked for the default module.

appengine {
   run {
       port = 8005
       ...
   }
}
loosebazooka commented 6 years ago

It depends on what you do,

  1. You should be able to use modules api in com.google.appengine:appengine-api-1.0-sdk if you just want to talk to all the other services like this. I would recommend this approach as it will work in your production application as well:

    ModulesService modulesService = ModulesServiceFactory.getModulesService();
    for (String module : modulesService.getModules()) {
      // "no_version" is the version in the devappserver for modules.
      System.out.println(modulesService.getVersionHostname(module, "no_version")));
    }
  2. You can specify ports directly I think using a system property (in your build.gradle):

    appengine {
      run {
        jvmFlags = ['-Dcom.google.appengine.devappserver_module.MY_MODULE.port=8090']
      }
    }
kriim commented 6 years ago

Great, thanks, I was looking for something like the system property you mentioned in 2.

(It's just for local testing of a cron job service, so that the port won't change on every restart.)