Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple NodeJS Services/Modules on Google App Engine Flexible Environment

I'm struggling to figure out how to deploy multiple nodejs services on google app engine flexible.

I'm using multiple nodejs classes with firebase-queue to process my tasks. Right now, i'm using my package.json to trigger starting everything at once. However, this has become problematic. I would like to be able to push a change to one particular service/script without having to stop every other script.

My package.json currently looks like something like this:

"scripts": {
    "task1": "node ./src/task1.js",
    "task2": "node ./src/task2.js",
    "start": "npm-run-all -p task1 task2"
}

I'm using different .yaml files to determine which build variant I want to push (Debug or Release) but am finding it hard to deploy each task individually. I found documentation on how to do so in python, but nothing on nodejs. Does anyone have any suggestions?

like image 342
Alan Avatar asked Dec 18 '22 12:12

Alan


1 Answers

(Answering my own question, big thanks to Justin for helping)

I was specifically having issues dynamically changing the script to start in my package.json. I found the package.json can access environment variables using '$'

package.json:

"scripts": {
    "start": "node $SCRIPT_TO_RUN"
}

myService.yaml

runtime: nodejs
vm: true
api_version: 1
instance_class: B4
manual_scaling:
  instances: 1
service: cart-monitor-dev

env_variables:
  SCRIPT_TO_RUN: './src/mytask.js'

Then deploy using:

gcloud app deploy myService.yaml
like image 168
Alan Avatar answered May 23 '23 14:05

Alan