diff --git a/README.md b/README.md index 1f682a0..a91b789 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/attach.js b/attach.js new file mode 100644 index 0000000..4ffdb60 --- /dev/null +++ b/attach.js @@ -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(); diff --git a/monitor.js b/monitor.js new file mode 100644 index 0000000..875f294 --- /dev/null +++ b/monitor.js @@ -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();