File tree Expand file tree Collapse file tree 4 files changed +60
-0
lines changed Expand file tree Collapse file tree 4 files changed +60
-0
lines changed Original file line number Diff line number Diff line change 1+ FROM microsoft/powershell:ubuntu16.04
2+
3+ RUN curl -sSLf https://github.com/openfaas-incubator/of-watchdog/releases/download/0.4.2/of-watchdog > /usr/bin/fwatchdog \
4+ && chmod +x /usr/bin/fwatchdog
5+ WORKDIR /root/
6+
7+ COPY server.ps1 server.ps1
8+
9+ COPY function function
10+
11+ HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1
12+
13+ ENV fprocess="pwsh ./server.ps1"
14+ ENV cgi_headers="true"
15+ ENV mode="http"
16+ ENV upstream_url="http://127.0.0.1:8081"
17+
18+ EXPOSE 8080
19+ CMD ["fwatchdog" ]
Original file line number Diff line number Diff line change 1+ # Rename input for better readability
2+ $funcInput = $args
3+ $output = " Hello! Your input was: " + $funcInput
4+
5+ # Must provide an output variable for the main process to return
6+ $output
Original file line number Diff line number Diff line change 1+ Add-Type - AssemblyName System.Web
2+
3+ $listener = New-Object System.Net.HttpListener
4+ $listener.Prefixes.Add (" http://*:8081/" )
5+ $listener.Start ()
6+
7+ do {
8+ $context = $listener.GetContext ()
9+ $response = $context.Response
10+ $Content = " "
11+
12+ $reqStream = $context.Request.InputStream
13+ $reqEncoding = $context.Request.ContentEncoding
14+
15+ $reader = [System.IO.StreamReader ]::new($reqStream , $reqEncoding )
16+
17+ $reqBody = $reader.ReadToEnd ()
18+
19+ try {
20+ $funcResult = . .\function\handler.ps1 $reqBody
21+
22+ $Content = [System.Text.Encoding ]::UTF8.GetBytes($funcResult )
23+ $response.StatusCode = 200
24+ }
25+ catch {
26+ $Content = [System.Text.Encoding ]::UTF8.GetBytes(" $_ .Exception.Message" )
27+ $response.StatusCode = 500
28+ }
29+
30+ $response.ContentLength64 = $Content.Length
31+ $response.OutputStream.Write ($Content , 0 , $Content.Length )
32+ $response.Close ()
33+ } while ($listener.IsListening )
Original file line number Diff line number Diff line change 1+ language : powershell-http
2+ fprocess : pwsh server.ps1
You can’t perform that action at this time.
0 commit comments