0
votes

Sometimes I just need to make small changes to my code, such as changing a variable's value (on the Nodejs app.js hosted on Google Cloud). Is there a way to update the file without going thru the process of deploying the whole application by "gcloud app deploy" ?

1

1 Answers

0
votes

No, the application's code can only be updated by redeploying.

However, if you are only changing variable values, instead of hardcoding them you can instead use GET parameters and pass the values from the url. This way you don't have to make any code changes to change the values and therefore no need to redeploy.

Example from modified official Nodejs sample:

'use strict';

const express = require('express');
const app = express();

app.get('/', (req, res) => {

  var my_param = req.query.param;
  res
    .status(200)
    .send('The url gave me this: ' + my_param)
    .end();
});

// Start the server
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
  console.log(`App listening on port ${PORT}`);
  console.log('Press Ctrl+C to quit.');
});

So then you add the param value in the url, for example:

https://your-project.appspot.com/?param=123

And that would result in:

The url gave me this: 123