Skip to content

test: do not trigger node bug with fd mapping #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ signalled with SIGHUP, see
### slc run

``` text
usage: slc run [options] [app [app-options...]]
usage: slr [options] [app [app-options...]]

Run an app, allowing it to be profiled (using StrongOps) and supervised.
Expand All @@ -203,14 +202,15 @@ Options:
Disable timestamping of supervisor log messages.
--syslog Send supervisor and collected worker logs to syslog,
unsupported on Windows.
--metrics BACKEND Send metrics to custom backend (default is no custom).
--metrics BACKEND Report metrics to custom backend. Implies `--profile`.
-p,--pid FILE Write supervisor's pid to FILE, failing if FILE already
has a valid pid in it (default is no pid file).
--cluster N Set the cluster size (default is off, but see below).
--no-profile Disable reporting profile data to StrongOps (default is to
profile if registration data is found). Does not affect
local reporting using --metrics option.
-C,--control CTL Listen for local control messages on CTL (default `pmctl),
--profile Start the agent. Report to StrongOps if registration data
is found (this is the default).
--no-profile Do not start the agent, do not report to StrongOps,
do not report metrics.
-C,--control CTL Listen for local control messages on CTL (default `pmctl`),
only supported when clustered.
--no-control Do not listen for local control messages.

Expand Down
45 changes: 36 additions & 9 deletions bin/sl-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,42 @@ process.on('disconnect', function() {
var config = require('../lib/config'); // May exit, depending on argv
var log = config.logger;

if(!config.profile) {
if(config.isMaster) {
log.error('supervisor running without StrongOps (unprofiled)');
}
} else {
require('strong-agent').profile(undefined, undefined, {
quiet: config.isWorker, // Quiet in worker, to avoid repeated log messages
logger: config.logger,
});
var agent = require('../lib/agent');
var agentOptions = {
quiet: config.isWorker, // Quiet in worker, to avoid repeated log messages
logger: config.logger,
};

switch(config.profile) {
case false: // Profiling explicitly disabled.
if(config.isMaster) {
log.error('supervisor running without profiling');
}
break;

case undefined: // No explicit request for profiling or metrics.
// Start with StrongOps if app is registered. This will print warning
// messages to the console if the api key is not found, which is backwards
// compatible.
agent().profile(undefined, undefined, agentOptions);
// Otherwise, just start. This is a no-op if it is already started.
agent().start();
break;

case true: // Profiling or metrics explicitly enabled.
agent().configure(agentOptions);
// Only try to start StrongOps if they have registered, to avoid legacy
// warning messages. If an app is missing a name, profile may still fail
// to start, so drop-through to start(). We must re-supply options.
if (agent().config.key)
agent().profile(undefined, undefined, agentOptions);
// Otherwise, just start. This is a no-op if already started.
agent().start();
break;

default:
assert(false, 'invalid profile value');
break;
}

if((config.clustered && config.isMaster) || config.detach){
Expand Down
11 changes: 6 additions & 5 deletions bin/sl-run.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ Options:
Disable timestamping of supervisor log messages.
--syslog Send supervisor and collected worker logs to syslog,
unsupported on Windows.
--metrics BACKEND Send metrics to custom backend (default is no custom).
--metrics BACKEND Report metrics to custom backend. Implies `--profile`.
-p,--pid FILE Write supervisor's pid to FILE, failing if FILE already
has a valid pid in it (default is no pid file).
--cluster N Set the cluster size (default is off, but see below).
--no-profile Disable reporting profile data to StrongOps (default is to
profile if registration data is found). Does not affect
local reporting using --metrics option.
-C,--control CTL Listen for local control messages on CTL (default `pmctl),
--profile Start the agent. Report to StrongOps if registration data
is found (this is the default).
--no-profile Do not start the agent, do not report to StrongOps,
do not report metrics.
-C,--control CTL Listen for local control messages on CTL (default `pmctl`),
only supported when clustered.
--no-control Do not listen for local control messages.

Expand Down
6 changes: 5 additions & 1 deletion lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exports.parse = function parse(argv) {
HELP: exports.HELP,
argv: argv, // process.argv stripped of command...
args: [ '.' ], // app app-options...
profile: true,
profile: process.env.STRONGLOOP_METRICS ? true : undefined,
channel: 'runctl',
log: false,
metrics: null,
Expand Down Expand Up @@ -75,10 +75,12 @@ exports.parse = function parse(argv) {
i++;
options.metrics = options.metrics || []
options.metrics.push(argv[i]);
options.profile = true;
}
else if(/^--metrics=/.test(option)) {
options.metrics = options.metrics || []
options.metrics.push(value(option));
options.profile = true;
}
else if(option === '--pid' || option === '-p') {
i++;
Expand All @@ -92,6 +94,8 @@ exports.parse = function parse(argv) {
}
else if(option === '--no-profile') {
options.profile = false;
options.metrics = null;
delete process.env.STRONGLOOP_METRICS;
}
else if(option === '--cluster') {
i++;
Expand Down
4 changes: 1 addition & 3 deletions test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ exports.runWithControlChannel = function(appWithArgs, runArgs, onMessage) {
}

var options = {
// NOTE(bajtos) We are redirecting stdout to stderr in order to keep
// the test output clean from diagnostic messages.
stdio: [0, 2, 2, 'ipc'],
stdio: [0, 1, 2, 'ipc'],
env: util._extend({
SL_ENV: 'test',
STRONGLOOP_FLUSH_INTERVAL: 2,
Expand Down
7 changes: 5 additions & 2 deletions test/test-run-metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ var util = require('util');

tap.test('metrics', function(t) {
var plan = 1; // for internal
var runArgs = [];
var runArgs = [
'--cluster=1',
'--no-profile',
];

async.parallel([
startGraphite,
Expand All @@ -39,7 +42,7 @@ tap.test('metrics', function(t) {
function run() {
helper.runWithControlChannel(
require.resolve('./module-app'),
['--cluster=1', '--no-profile'],
runArgs,
onRequest);
}

Expand Down