File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -123,3 +123,36 @@ Connections Ready! [
123123]
124124tunnel process exited with code 0
125125```
126+
127+ ### Service
128+
129+ Checkout [ ` examples/service.js ` ] ( examples/service.js ) .
130+
131+ ``` js
132+ import { service } from " cloudflared" ;
133+
134+ console .log (" Cloudflared Service Example." );
135+ main ();
136+
137+ async function main () {
138+ if (service .exists ()) {
139+ console .log (" Service is running." );
140+ const current = service .current ();
141+ for (const { service , hostname } of current .config .ingress ) {
142+ console .log (` - ${ service} -> ${ hostname} ` );
143+ }
144+ console .log (" metrics server:" , current .metrics );
145+ } else {
146+ console .log (" Service is not running." );
147+ }
148+ }
149+ ```
150+
151+ ``` sh
152+ ❯ node examples/service.js
153+ Cloudflared Service Example.
154+ Service is running.
155+ - http://localhost:12345 -> sub.example.com
156+ - http_status:404 -> undefined
157+ metrics server: 127.0.0.1:49177/metrics
158+ ```
Original file line number Diff line number Diff line change 1+ import { service } from "../lib/lib.js" ;
2+
3+ console . log ( "Cloudflared Service Example." ) ;
4+ main ( ) ;
5+
6+ async function main ( ) {
7+ if ( service . exists ( ) ) {
8+ console . log ( "Service is running." ) ;
9+ const current = service . current ( ) ;
10+ for ( const { service, hostname } of current . config . ingress ) {
11+ console . log ( ` - ${ service } -> ${ hostname } ` ) ;
12+ }
13+ console . log ( "metrics server:" , current . metrics ) ;
14+ } else {
15+ console . log ( "Service is not running." ) ;
16+ }
17+ }
You can’t perform that action at this time.
0 commit comments