|
| 1 | +# Enable Hot Reload when developing OCI Functions locally |
| 2 | + |
| 3 | +When developing Functions locally, Fn allows you to enable hot reload. When hot reload is enabled, your changes will be |
| 4 | +automatically detected and will trigger function local deployment to the application that you have specified. |
| 5 | + |
| 6 | +## Before you Begin |
| 7 | +* Set aside about 15 minutes to complete this tutorial. |
| 8 | +* Make sure Fn server is up and running by completing the [Install and Start Fn Tutorial](../install/README.md). |
| 9 | + * Make sure you have set your Fn context registry value for local development. (for example, "fndemouser". [See here](https://github.com/fnproject/tutorials/blob/master/install/README.md#configure-your-context).) |
| 10 | + |
| 11 | +As you make your way through this tutorial, look out for this icon.  Whenever you see it, it's time for you to perform an |
| 13 | +action. |
| 14 | + |
| 15 | + |
| 16 | +## Start Fn |
| 17 | +In the terminal, type the following to start Fn. Optionally, you could start with "--log-level DEBUG" arguments so you |
| 18 | +could see more messages. |
| 19 | + |
| 20 | + |
| 21 | +>```sh |
| 22 | +> fn start --log-level DEBUG |
| 23 | +>``` |
| 24 | +
|
| 25 | + |
| 26 | +
|
| 27 | +## Hot Reload for Python Function |
| 28 | +
|
| 29 | +Suppose you have an application called "myapp" that setup locally, and you have initialized a function called "myfunc". Under the |
| 30 | +functions directory, where the func.yaml located, you could run the following to enable Hot Reload. |
| 31 | +
|
| 32 | + |
| 33 | +>```sh |
| 34 | +> fn watch -app myapp |
| 35 | +>``` |
| 36 | +
|
| 37 | + |
| 38 | +
|
| 39 | +Now you could change the code for Functions. Here we modify the output string from "Hello" to "Hi". |
| 40 | +
|
| 41 | +You could see that the local deployment will be triggered automatically. |
| 42 | +
|
| 43 | +
|
| 44 | + |
| 45 | +
|
| 46 | +If you invoke the function, you could see the new change: |
| 47 | +
|
| 48 | + |
| 49 | +
|
| 50 | +
|
| 51 | +## Supported Language |
| 52 | +All languages supported by OCI Functions have hot reload feature supported. |
| 53 | +
|
| 54 | +## Ignoring paths |
| 55 | +`fn watch` ignores these directories by default: |
| 56 | +
|
| 57 | +- `.git`, `.fn`, `node_modules`, `target`, `dist`, `vendor`, `Dockerfile-fn-tmp*` |
| 58 | +
|
| 59 | +You can add more ignore rules by creating a `.fnignore` file in the watched directory (one pattern per line; `#` comments supported), and/or by passing `--ignore` flags. |
| 60 | +
|
| 61 | +
|
0 commit comments