<commit_before>import grails.util.Environment

import thepieuvre.core.ArticleTask
import thepieuvre.core.FeederTask
import thepieuvre.core.FeedParser
import thepieuvre.member.Member
import thepieuvre.security.Role
import thepieuvre.security.User
import thepieuvre.security.UserRole

class BootStrap {

    def queuesService
    def schedulerService

    def grailsApplication

    private Thread feedParser = null

    def init = { servletContext ->
    	def roles = [
    		['ROLE_ROOT', 'The super administrator of the system'],
            ['ROLE_FEED_MANAGER', 'Manager of Feeds'],
            ['ROLE_FEED_API', 'API user for feed managing'],
            ['ROLE_MEMBER_MANAGER', 'Manager of Members'],
            ['ROLE_MEMBER', 'Member'],
            ['ROLE_COMMAND_MANAGER', 'Manager of Commands']
    	].each { name, description ->
    		def role = Role.findByAuthority(name)
    		if( ! role) {
    			role = new Role(authority: name, description: description)
    			role.save(failOnError: true, flush: true)
    		}
    	}

        // Alex is the super-administrator
        def alexUser = User.findByUsername('alex')
        if (!alexUser) {
            def alexpass = (Environment.PRODUCTION == Environment.current ? '***REMOVED***' : 'alex')
            alexUser = new Member(
                email: '<EMAIL>',
                username: 'alex',
                password: <PASSWORD>,
                enabled: 'true',
                canPasswordLogin: true,
                verified: new Date()
            )
            if (!alexUser.save()) {
                println alexUser.errors
            }
            
            UserRole.create(alexUser, Role.findByAuthority('ROLE_ROOT'), true)
            UserRole.create(alexUser, Role.findByAuthority('ROLE_MEMBER'), true)
        }

        queuesService.queues.each {k,v->
            queuesService.create(v)
        }

        schedulerService.schedule(new FeederTask(grailsApplication), 31415)
        feedParser = new Thread(new FeedParser(grailsApplication)).start()
        def articleTask = new Thread(new ArticleTask(grailsApplication)).start()<commit_msg>Initializing Threads with number of cores<commit_after>import grails.util.Environment

import thepieuvre.core.ArticleTask
import thepieuvre.core.FeederTask
import thepieuvre.core.FeedParser
import thepieuvre.member.Member
import thepieuvre.security.Role
import thepieuvre.security.User
import thepieuvre.security.UserRole

class BootStrap {

    def queuesService
    def schedulerService

    def grailsApplication

    static int cores = Runtime.getRuntime().availableProcessors()

    def init = { servletContext ->
    	def roles = [
    		['ROLE_ROOT', 'The super administrator of the system'],
            ['ROLE_FEED_MANAGER', 'Manager of Feeds'],
            ['ROLE_FEED_API', 'API user for feed managing'],
            ['ROLE_MEMBER_MANAGER', 'Manager of Members'],
            ['ROLE_MEMBER', 'Member'],
            ['ROLE_COMMAND_MANAGER', 'Manager of Commands']
    	].each { name, description ->
    		def role = Role.findByAuthority(name)
    		if( ! role) {
    			role = new Role(authority: name, description: description)
    			role.save(failOnError: true, flush: true)
    		}
    	}

        // Alex is the super-administrator
        def alexUser = User.findByUsername('alex')
        if (!alexUser) {
            def alexpass = (Environment.PRODUCTION == Environment.current ? '***REMOVED***' : 'alex')
            alexUser = new Member(
                email: '<EMAIL>',
                username: 'alex',
                password: <PASSWORD>,
                enabled: 'true',
                canPasswordLogin: true,
                verified: new Date()
            )
            if (!alexUser.save()) {
                println alexUser.errors
            }
            
            UserRole.create(alexUser, Role.findByAuthority('ROLE_ROOT'), true)
            UserRole.create(alexUser, Role.findByAuthority('ROLE_MEMBER'), true)
        }

        queuesService.queues.each {k,v->
            queuesService.create(v)
        }

        schedulerService.schedule(new FeederTask(grailsApplication), 31415)

        cores.times {
            def feedParser = new Thread(new FeedParser(grailsApplication)).start()
            def articleTask = new Thread(new ArticleTask(grailsApplication)).start()
            println "Starting FeedParser and ArticleTask on Core $it"
        } 
{'fraction_non_alphanumeric': 0.10305084745762712, 'fraction_numerical': 0.0022598870056497176, 'mean_word_length': 2.3153558052434455, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '2468583', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1236, 'n_words': 282}