Skip to content

Commit

Permalink
Support preloading (#144)
Browse files Browse the repository at this point in the history
* Add REST API

* remove debug

* Separate REST functions

* Correct returned uris

* Formatting errors

* Add REST tests

* enable preloading

* comment
  • Loading branch information
sjanuary authored and tobespc committed Jun 6, 2018
1 parent c96afaf commit 44c3b84
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ require('appmetrics-dash').attach();
```
to the very top of your main JavaScript source file.

Alternatively, to use preloading:

```sh
$ node --require appmetrics-dash/attach app.js
```

or in Node.js from versions 8.0.0 and 6.12.0 onwards, use the NODE_OPTIONS environment variable:

```sh
$ export NODE_OPTIONS="--require appmetrics-dash/attach"
```

If you want to add the dashboard to one specific HTTP server then use:

```js
Expand All @@ -31,6 +43,18 @@ If you are not creating an HTTP server then use:
require('appmetrics-dash').monitor();
```

or run your program with

```sh
$ node --require appmetrics-dash/monitor app.js
```

or via the NODE_OPTIONS environment variable:

```sh
$ export NODE_OPTIONS="--require appmetrics-dash/monitor"
```

This creates a new server for the dashboard on port 3001 by default. The path defaults to ```/appmetrics-dash```.
E.g. http://localhost:3001/appmetrics-dash

Expand Down
18 changes: 18 additions & 0 deletions attach.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*******************************************************************************
* Copyright 2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
// For preloading
'use strict';
require('./lib/appmetrics-dash.js').attach();
18 changes: 18 additions & 0 deletions monitor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*******************************************************************************
* Copyright 2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
// For preloading
'use strict';
require('./lib/appmetrics-dash.js').monitor();

0 comments on commit 44c3b84

Please sign in to comment.