<commit_before>#########
# Copyright (c) 2015 GigaSpaces Technologies Ltd. All rights reserved
#
# 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.

import os

from cloudify.exceptions import CommandExecutionException

from cloudify_agent.api import utils
from cloudify_agent.api import exceptions
from cloudify_agent import VIRTUALENV
from cloudify_agent.api import defaults
from cloudify_agent.included_plugins import included_plugins
from cloudify_agent.api.pm.base import CronRespawnDaemon


class GenericLinuxDaemon(CronRespawnDaemon):

    """
    Implementation for the init.d process management.

    Following are all possible custom key-word arguments
    (in addition to the ones available in the base daemon)

    ``start_on_boot``

        start this daemon when the system boots.

    """

    SCRIPT_DIR = '/etc/init.d'
    CONFIG_DIR = '/etc/default'
    PROCESS_MANAGEMENT = 'init.d'

    def __init__(self, logger=None, **params):
        super(GenericLinuxDaemon, self).__init__(logger=logger, **params)

        self.service_name = 'celeryd-{0}'.format(self.name)
        self.script_path = os.path.join(self.SCRIPT_DIR, self.service_name)
        self.config_path = os.path.join(self.CONFIG_DIR, self.service_name)
        self.includes_path = os.path.join(
            self.workdir, '{0}-includes'.format(self.name))

        # initd specific configuration
        self.start_on_boot = params.get('start_on_boot', False)

    def configure(self):

        self._logger.debug('Creating includes file: {0}'
                           .format(self.includes_path))
        self._create_includes()
        self._logger.debug('Creating daemon script: {0}'
                           .format(self.script_path))
        self._create_script()
        self._logger.debug('Creating daemon conf file: {0}'
                           .format(self.config_path))
        self._create_config()
<commit_msg>CFY-3859 set init.d start_on_boot default value to true<commit_after>#########
# Copyright (c) 2015 GigaSpaces Technologies Ltd. All rights reserved
#
# 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.

import os

from cloudify.exceptions import CommandExecutionException

from cloudify_agent.api import utils
from cloudify_agent.api import exceptions
from cloudify_agent import VIRTUALENV
from cloudify_agent.api import defaults
from cloudify_agent.included_plugins import included_plugins
from cloudify_agent.api.pm.base import CronRespawnDaemon


class GenericLinuxDaemon(CronRespawnDaemon):

    """
    Implementation for the init.d process management.

    Following are all possible custom key-word arguments
    (in addition to the ones available in the base daemon)

    ``start_on_boot``

        start this daemon when the system boots.

    """

    SCRIPT_DIR = '/etc/init.d'
    CONFIG_DIR = '/etc/default'
    PROCESS_MANAGEMENT = 'init.d'

    def __init__(self, logger=None, **params):
        super(GenericLinuxDaemon, self).__init__(logger=logger, **params)

        self.service_name = 'celeryd-{0}'.format(self.name)
        self.script_path = os.path.join(self.SCRIPT_DIR, self.service_name)
        self.config_path = os.path.join(self.CONFIG_DIR, self.service_name)
        self.includes_path = os.path.join(
            self.workdir, '{0}-includes'.format(self.name))

        # initd specific configuration
        self.start_on_boot = params.get('start_on_boot', True)

    def configure(self):

        self._logger.debug('Creating includes file: {0}'
                           .format(self.includes_path))
        self._create_includes()
        self._logger.debug('Creating daemon script: {0}'
                           .format(self.script_path))
        self._create_script()
        self._logger.debug('Creating daemon conf file: {0}'
                           .format(self.config_path))
        self._create_config()

{'fraction_non_alphanumeric': 0.09111430330391955, 'fraction_numerical': 0.00615637184485943, 'mean_word_length': 3.208981001727116, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2621229', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1345, 'n_words': 413}