mirror of
https://github.com/openfaas/faas.git
synced 2025-06-09 16:56:47 +00:00
Update troubleshooting.md
This commit is contained in:
parent
41da1afea4
commit
272bfe0563
@ -1,5 +1,63 @@
|
|||||||
# Troubleshooting guide
|
# Troubleshooting guide
|
||||||
|
|
||||||
|
## Watchdog
|
||||||
|
|
||||||
|
### Debug your function without deploying it
|
||||||
|
|
||||||
|
Here's an example of how you can deploy a function without using an orchestrator - it's useful for testing:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ docker run --name debug-alpine \
|
||||||
|
-p 8081:8080 -ti functions/alpine:latest sh
|
||||||
|
# fprocess=date fwatchdog &
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you can access the function with one of the supported HTTP methods such as GET/POST etc:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ curl -4 localhost:8081
|
||||||
|
```
|
||||||
|
|
||||||
|
### Edit your function without rebuilding it
|
||||||
|
|
||||||
|
You can bind-mount code straight into your function and work with it locally, until you are ready to re-build. This is a common flow with containers, but should be used sparingly.
|
||||||
|
|
||||||
|
Within the CLI directory for instance:
|
||||||
|
|
||||||
|
Build the samples:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ git clone https://github.com/alexellis/faas-cli && \
|
||||||
|
cd faas-cli
|
||||||
|
$ faas-cli -action build -f ./samples.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
Now work with the Python-hello sample, with the code mounted live:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ docker run -v `pwd`/sample/url-ping/:/root/function/ \
|
||||||
|
--name debug-alpine -p 8081:8080 -ti alexellis/faas-url-ping sh
|
||||||
|
$ touch ./function/__init__.py
|
||||||
|
# fwatchdog
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you can start editing the code in the sample/url-ping folder and it will reload live for every request.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ curl localhost:8081 -d "https://www.google.com"
|
||||||
|
Handle this -> https://www.google.com
|
||||||
|
https://www.google.com => 200
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you can edit handler.py and you'll see the change immediately:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ echo "def handle(req):" > sample/url-ping/handler.py
|
||||||
|
$ echo ' print("Nothing to see here")' >> sample/url-ping/handler.py
|
||||||
|
$ curl localhost:8081 -d "https://www.google.com"
|
||||||
|
Nothing to see here
|
||||||
|
```
|
||||||
|
|
||||||
## Docker Swarm
|
## Docker Swarm
|
||||||
|
|
||||||
### List all functions
|
### List all functions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user