Skip to content

before_script

B1nj0y edited this page Oct 15, 2021 · 8 revisions

A before_script is just a normal Bash shell script located in the same folder with the function program file, you may use the before_script to:

  • do some preparation or set up environment before running the function program
  • install dependencies for those languages that we haven't supported dependency installation currently

The only point you should care is the before_script's name, it is the name of the function program file appended a .sh suffix. For example, if there's a function program file named func.py, its corresponding before_script's name should be func.py.sh.

You can find a test case example here. The script test_before_script.py.sh is a before_script for the function program test_before_script.py. We just use these two programs to test the before_script feature.

We also support Bash to create a Serverless service, see here. But it's unnecessary to write an additional before_script for Bash functions, you can just write all of it in the function code. Even you wrote a before_script for Bash functions, it won't be executed.

Note:

  1. add #!/bin/sh at first line
  2. run chmod +x <before_script> to make it executable
Clone this wiki locally