Startup script NOT running in instance

Viewed 28

I have a instance where I have some Flask web app. In order the app to start when the VM is booted I have included a startup script:

#!/bin/sh
cd documentai_webapp
cd docai_webapp_instance_gcp
sudo python3 server.py

However, this is not at all executed, anyone can help me?thanks!

PD: When I execute this script manually within the VM it works perfectly fine

1 Answers

As context it is necessary contemplate:

For Linux startup scripts, you can use bash or non-bash file. To use a non-bash file, designate the interpreter by adding a #! to the top of the file. For example, to use a Python 3 startup script, add #! /usr/bin/python3 to the top of the file.

If you specify a startup script by using one of the procedures in this document, Compute Engine does the following:

Copies the startup script to the VM

Sets run permissions on the startup script

Runs the startup script as the root user when the VM boots (missing step from @Andoni)

For information about the various tasks related to startup scripts and when to perform each one, see the Overview.

Related