<commit_before>// Copyright (C) 2007-2012, GoodData(R) Corporation. All rights reserved.

var fs = require('fs');
var Grizzly = require('../lib/grizzly');
var _ = require('lodash');

/**
 * grunt-grizzly
 */
module.exports = function(grunt) {
    'use strict';

    grunt.registerTask('grizzly', 'Run GoodData proxy server', function() {
        // Options passed via command line
        var cliOptions = {
            root: grunt.option('root') || grunt.option('dir'),
            host: grunt.option('backend') || grunt.option('host'),
            port: grunt.option('port'),
            cert: grunt.option('cert'),
            key: grunt.option('key'),
            keepAlive: this.flags.keepAlive,
            quiet: this.flags.quiet
        };

        // Grunt configuration created via grunt.initConfig
        var configOptions = grunt.config('grizzly.options') || {};

        // Check aliases
        configOptions.host = configOptions.host || configOptions.backend;
        configOptions.root = configOptions.root || configOptions.dir;

        // Create options object
        // CLI options have higher priority over grunt configuration options
        var options = _.defaults(cliOptions, configOptions);

        var done = this.async();
        var grizzly = new Grizzly(options);

        // Shutdown & notify on error
        grizzly.on('error', function(error) {
            console.error('Grizzly error: %s', error);
            console.error('Stopping task grizzly');

            done();
        });

        grizzly.on('start', function() {
            // Continue to next task if keepAlive is not set
            options.keepAlive || done();

            options.quiet || grizzly.printStartedMessage();
        });

        grizzly.on('close', function() {
            console.error('Grizzly server closed');
            console.error('Stopping task grizzly');

            done();
        });

        // Start grizzly server
        grizzly.start();
    });
};<commit_msg>BUGFIX: CL-3372 Grizzly should throw an exception on server error<commit_after>// Copyright (C) 2007-2012, GoodData(R) Corporation. All rights reserved.

var fs = require('fs');
var Grizzly = require('../lib/grizzly');
var _ = require('lodash');

/**
 * grunt-grizzly
 */
module.exports = function(grunt) {
    'use strict';

    grunt.registerTask('grizzly', 'Run GoodData proxy server', function() {
        // Options passed via command line
        var cliOptions = {
            root: grunt.option('root') || grunt.option('dir'),
            host: grunt.option('backend') || grunt.option('host'),
            port: grunt.option('port'),
            cert: grunt.option('cert'),
            key: grunt.option('key'),
            keepAlive: this.flags.keepAlive,
            quiet: this.flags.quiet
        };

        // Grunt configuration created via grunt.initConfig
        var configOptions = grunt.config('grizzly.options') || {};

        // Check aliases
        configOptions.host = configOptions.host || configOptions.backend;
        configOptions.root = configOptions.root || configOptions.dir;

        // Create options object
        // CLI options have higher priority over grunt configuration options
        var options = _.defaults(cliOptions, configOptions);

        var done = this.async();
        var grizzly = new Grizzly(options);

        // Shutdown & notify on error
        grizzly.on('error', function(error) {
            grunt.log.error('Grizzly error: %s', error);
            grunt.log.error('Stopping task grizzly');

            throw error;
        });

        grizzly.on('start', function() {
            // Continue to next task if keepAlive is not set
            options.keepAlive || done();

            options.quiet || grizzly.printStartedMessage();
        });

        grizzly.on('close', function() {
            grunt.log.error('Grizzly server closed');
            grunt.log.error('Stopping task grizzly');

            done();
        });

        // Start grizzly server
        grizzly.start();
    });
};
{'fraction_non_alphanumeric': 0.13303769401330376, 'fraction_numerical': 0.004927322000492732, 'mean_word_length': 2.161993769470405, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6390166', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1120, 'n_words': 274}