diff --git a/HotReload/README.md b/HotReload/README.md new file mode 100644 index 0000000..0d06daa --- /dev/null +++ b/HotReload/README.md @@ -0,0 +1,61 @@ +# Enable Hot Reload when developing OCI Functions locally + +When developing Functions locally, Fn allows you to enable hot reload. When hot reload is enabled, your changes will be +automatically detected and will trigger function local deployment to the application that you have specified. + +## Before you Begin +* Set aside about 15 minutes to complete this tutorial. +* Make sure Fn server is up and running by completing the [Install and Start Fn Tutorial](../install/README.md). + * 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).) + +As you make your way through this tutorial, look out for this icon. ![User Input +Icon](images/userinput.png) Whenever you see it, it's time for you to perform an +action. + + +## Start Fn +In the terminal, type the following to start Fn. Optionally, you could start with "--log-level DEBUG" arguments so you +could see more messages. + +![User Input Icon](images/userinput.png) +>```sh +> fn start --log-level DEBUG +>``` + +![Start Fn Server](images/fnstart.png) + +## Hot Reload for Python Function + +Suppose you have an application called "myapp" that setup locally, and you have initialized a function called "myfunc". Under the +functions directory, where the func.yaml located, you could run the following to enable Hot Reload. + +![User Input Icon](images/userinput.png) +>```sh +> fn watch -app myapp +>``` + +![Enable Hot Reload](images/fnwatch.png) + +Now you could change the code for Functions. Here we modify the output string from "Hello" to "Hi". + +You could see that the local deployment will be triggered automatically. + + +![Local Deployment Triggered](images/hotreload.png) + +If you invoke the function, you could see the new change: + +![Fn Invoke](images/fninvoke.png) + + +## Supported Language +All languages supported by OCI Functions have hot reload feature supported. + +## Ignoring paths +`fn watch` ignores these directories by default: + +- `.git`, `.fn`, `node_modules`, `target`, `dist`, `vendor`, `Dockerfile-fn-tmp*` + +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. + + diff --git a/HotReload/images/fninvoke.png b/HotReload/images/fninvoke.png new file mode 100644 index 0000000..1cb2b24 Binary files /dev/null and b/HotReload/images/fninvoke.png differ diff --git a/HotReload/images/fnstart.png b/HotReload/images/fnstart.png new file mode 100644 index 0000000..ca2d251 Binary files /dev/null and b/HotReload/images/fnstart.png differ diff --git a/HotReload/images/fnwatch.png b/HotReload/images/fnwatch.png new file mode 100644 index 0000000..196403b Binary files /dev/null and b/HotReload/images/fnwatch.png differ diff --git a/HotReload/images/hotreload.png b/HotReload/images/hotreload.png new file mode 100644 index 0000000..651a409 Binary files /dev/null and b/HotReload/images/hotreload.png differ diff --git a/HotReload/images/userinput.png b/HotReload/images/userinput.png new file mode 100644 index 0000000..ce6a202 Binary files /dev/null and b/HotReload/images/userinput.png differ diff --git a/README.md b/README.md index a3a901e..d8c0c1d 100644 --- a/README.md +++ b/README.md @@ -24,12 +24,12 @@ Official: * [Fn Development with Multiple Contexts](basics/UsingContexts/README.md) - Shows how to setup and use multiple Fn configuration contexts for development. * [Using Fn RuntimeContext with a Function](basics/UsingRuntimeContext/README.md) - See how to set Fn Application and Function variables and access them in your function using the Runtime Context. - ## Test and Monitor Functions * [Monitor Fn metrics with Grafana and Prometheus](grafana/README.md) - Learn how to view Fn server metrics with Prometheus and Grafana. * [Troubleshoot and Log functions](Troubleshooting/README.md) - Resolve issues at both development and deployment time. * [Debug functions locally](LocalDebug/README.md) - Deploy functions locally and debug. +* [Enable Hot Reload when developing OCI Functions locally](HotReload/README.md) - Enable hot reload when developing Functions locally with Fn Server ## Orchestrate with Fn Flow