<commit_before>import libc
import Console
import Dispatch

extension Droplet {
    enum ExecutionError: Swift.Error {
        case insufficientArguments, noCommandFound
    }

    /**
        Runs the Droplet's commands, defaulting to serve.
    */
    public func run(servers: [String: ServerConfig]? = nil) -> Never  {
        do {
            try runCommands(servers: servers)
            let group = DispatchGroup()
            group.enter()
            group.wait()
            exit(0)
        } catch CommandError.general(let error) {
            console.output(error, style: .error)
            exit(1)
        } catch ConsoleError.help {
            exit(0)
        } catch ConsoleError.cancelled {
            exit(2)
        } catch ConsoleError.commandNotFound(let command) {
            console.error("Error: ", newLine: false)
            console.print("Command \"\(command)\" not found.")
            exit(1)
        } catch {
            console.error("Error: ", newLine: false)
            console.print("\(error)")
            exit(1)
        }
    }

    func runCommands(servers: [String: ServerConfig]? = nil) throws {
        // the prepare command will run all
        // of the supplied preparations on the database.
        let prepare = Prepare(console: console, preparations: self.preparations, database: self.database)

        // the serve command will boot the servers
        // and always runs the prepare command
        let serve = Serve(console: console, prepare: prepare) {
            try self.startServers(servers)<commit_msg>Fix: Process will now exit if no servers are started after `run`<commit_after>import libc
import Console
import Dispatch

extension Droplet {
    enum ExecutionError: Swift.Error {
        case insufficientArguments, noCommandFound
    }

    /**
        Runs the Droplet's commands, defaulting to serve.
    */
    public func run(servers: [String: ServerConfig]? = nil) -> Never  {
        do {
            try runCommands(servers: servers)
            if (self.startedServers.count > 0) {
                // if servers were started, wait (forever) on a DispatchGroup to prevent the process from exiting
                let group = DispatchGroup()
                group.enter()
                group.wait()
            }
            exit(0)
        } catch CommandError.general(let error) {
            console.output(error, style: .error)
            exit(1)
        } catch ConsoleError.help {
            exit(0)
        } catch ConsoleError.cancelled {
            exit(2)
        } catch ConsoleError.commandNotFound(let command) {
            console.error("Error: ", newLine: false)
            console.print("Command \"\(command)\" not found.")
            exit(1)
        } catch {
            console.error("Error: ", newLine: false)
            console.print("\(error)")
            exit(1)
        }
    }

    func runCommands(servers: [String: ServerConfig]? = nil) throws {
        // the prepare command will run all
        // of the supplied preparations on the database.
        let prepare = Prepare(console: console, preparations: self.preparations, database: self.database)

        // the serve command will boot the servers
        // and always runs the prepare command
        let serve = Serve(console: console, prepare: prepare) {
            try self.startServers(servers)
{'fraction_non_alphanumeric': 0.09595959595959595, 'fraction_numerical': 0.0038621509209744503, 'mean_word_length': 1.9431818181818181, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '6424618', 'n_tokens_mistral': 882, 'n_tokens_neox': 859, 'n_words': 260}