Changing startup port on Scala SDK

In the Java sdk, I can start the service, locally, with a different port, through the use of the PORT env variable. I try that with the Scala SDK and it does not work.

How can I configure the sbt run command to use a different port than 8080?

I suspect answer could be here:Unsure How Calling Another Service Works? - #3 by HarveyEllis

but haven’t confirmed.

The PORT environment variable should be used by the Scala SDK. I tried

export PORT=8081
sbt run
...
14:53:43.705 [akkaserverless-akka.actor.default-dispatcher-4] DEBUG akka.io.TcpListener - Successfully bound to /127.0.0.1:8081
14:53:43.712 [akkaserverless-akka.actor.default-dispatcher-4] DEBUG akka.actor.ActorSystemImpl - gRPC server started 127.0.0.1:8081

You might have to enable debug logging in logback.xml to see that log message:

<logger name="akka" level="DEBUG"/>

Weird. I could swear that I tried! Will try again! Thanks!

Maybe that helps for someone else (as I had the same problem running multiple services locally):

  • in the resource folder, create application.conf
    add the following:
    akkaserverless.user-function-port = 8081

of course for the akka-serverless-proxy (docker-compose.yaml) change ‘USER_FUNCTION_PORT’ accordingly:
akka-serverless-proxy:
image: Google Cloud Platform
command: -Dconfig.resource=dev-mode.conf -Dakkaserverless.proxy.eventing.support=google-pubsub-emulator
ports:
- “9001:9000”
extra_hosts:
- “host.docker.internal:host-gateway”
environment:
USER_FUNCTION_HOST: ${USER_FUNCTION_HOST:-host.docker.internal}
USER_FUNCTION_PORT: ${USER_FUNCTION_PORT:-8081}
PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator

Maybe an update on this page:

At the end of the page, there is a reference to ‘start’ method. It took me some time to know how to deal with that :slight_smile:

Did you solved your issue i have same issue and trying to figure it out suggest the answer.