Skip to content

Commit 4d7ec95

Browse files
authored
Merge pull request #237 from fnproject/marleung/hotreload
Doc for hot reload feature in Fn CLI for local Functions development
2 parents 596baea + 8578b04 commit 4d7ec95

7 files changed

Lines changed: 62 additions & 1 deletion

File tree

HotReload/README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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. ![User Input
12+
Icon](images/userinput.png) 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+
![User Input Icon](images/userinput.png)
21+
>```sh
22+
> fn start --log-level DEBUG
23+
>```
24+
25+
![Start Fn Server](images/fnstart.png)
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+
![User Input Icon](images/userinput.png)
33+
>```sh
34+
> fn watch -app myapp
35+
>```
36+
37+
![Enable Hot Reload](images/fnwatch.png)
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+
![Local Deployment Triggered](images/hotreload.png)
45+
46+
If you invoke the function, you could see the new change:
47+
48+
![Fn Invoke](images/fninvoke.png)
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+

HotReload/images/fninvoke.png

6.31 KB
Loading

HotReload/images/fnstart.png

138 KB
Loading

HotReload/images/fnwatch.png

16.5 KB
Loading

HotReload/images/hotreload.png

56.4 KB
Loading

HotReload/images/userinput.png

2.96 KB
Loading

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ Official:
2424
* [Fn Development with Multiple Contexts](basics/UsingContexts/README.md) - Shows how to setup and use multiple Fn configuration contexts for development.
2525
* [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.
2626

27-
2827
## Test and Monitor Functions
2928

3029
* [Monitor Fn metrics with Grafana and Prometheus](grafana/README.md) - Learn how to view Fn server metrics with Prometheus and Grafana.
3130
* [Troubleshoot and Log functions](Troubleshooting/README.md) - Resolve issues at both development and deployment time.
3231
* [Debug functions locally](LocalDebug/README.md) - Deploy functions locally and debug.
32+
* [Enable Hot Reload when developing OCI Functions locally](HotReload/README.md) - Enable hot reload when developing Functions locally with Fn Server
3333

3434
## Orchestrate with Fn Flow
3535

0 commit comments

Comments
 (0)