<commit_before>extern crate dotenv;
#[macro_use]
extern crate diesel;
extern crate argonautica;
#[macro_use]
extern crate anyhow;

use actix_files as fs;
use actix_identity::{CookieIdentityPolicy, IdentityService};
use actix_web::rt::Arbiter;
use actix_web::{guard, middleware, web, App, HttpResponse, HttpServer};
use background_jobs::memory_storage::Storage;
use background_jobs::{create_server, WorkerConfig};
use models::Picture;
use std::{env, io};
use webmentions::send::WebmenentionSenderJob;

use diesel::prelude::*;
use diesel::r2d2::{self, ConnectionManager};

use dotenv::dotenv;

use uri_helpers::webmentions_endpoint_uri;

pub mod multipart;
pub mod uri_helpers;
pub mod utils;

pub mod models;
pub mod schema;

pub mod articles;
pub mod likes;
pub mod notes;
pub mod pages;
pub mod pictures;
pub mod session;
pub mod static_handlers;
pub mod webmentions;

pub type DbPool = r2d2::Pool<ConnectionManager<PgConnection>>;
pub type DbError = Box<dyn std::error::Error + Send + Sync>;

const DEFAULT_QUEUE: &str = "default";

#[actix_web::main]
async fn main() -> io::Result<()> {
    dotenv().ok();

    env::set_var("RUST_LOG", "actix_web=debug,actix_server=info");
    env_logger::init();

    let connspec = std::env::var("DATABASE_URL").expect("DATABASE_URL");
    let manager = ConnectionManager::<PgConnection>::new(connspec);
    let pool = r2d2::Pool::builder().build(manager).expect("Failed to create pool.");

    HttpServer::new(move || {
        let static_path = utils::static_path();

        let storage = Storage::new();
        let queue = create_server(storage);

        WorkerConfig::new(|| ())
            .register::<WebmenentionSenderJob>()
            .register::<Picture>()
            .set_worker_count(DEFAULT_QUEUE, 1)
            .start_in_arbiter(&Arbiter::default(), queue.clone());

        App::new()
            .wrap(IdentityService::new(<commit_msg>call dotenv only in dev and test mode<commit_after>#[cfg(debug_assertions)]
extern crate dotenv;
#[macro_use]
extern crate diesel;
extern crate argonautica;
#[macro_use]
extern crate anyhow;

use actix_files as fs;
use actix_identity::{CookieIdentityPolicy, IdentityService};
use actix_web::rt::Arbiter;
use actix_web::{guard, middleware, web, App, HttpResponse, HttpServer};
use background_jobs::memory_storage::Storage;
use background_jobs::{create_server, WorkerConfig};
use models::Picture;
use std::{env, io};
use webmentions::send::WebmenentionSenderJob;

use diesel::prelude::*;
use diesel::r2d2::{self, ConnectionManager};

#[cfg(debug_assertions)]
use dotenv::dotenv;

use uri_helpers::webmentions_endpoint_uri;

pub mod multipart;
pub mod uri_helpers;
pub mod utils;

pub mod models;
pub mod schema;

pub mod articles;
pub mod likes;
pub mod notes;
pub mod pages;
pub mod pictures;
pub mod session;
pub mod static_handlers;
pub mod webmentions;

pub type DbPool = r2d2::Pool<ConnectionManager<PgConnection>>;
pub type DbError = Box<dyn std::error::Error + Send + Sync>;

const DEFAULT_QUEUE: &str = "default";

#[actix_web::main]
async fn main() -> io::Result<()> {
    #[cfg(debug_assertions)]
    dotenv().ok();

    env::set_var("RUST_LOG", "actix_web=debug,actix_server=info");
    env_logger::init();

    let connspec = std::env::var("DATABASE_URL").expect("DATABASE_URL");
    let manager = ConnectionManager::<PgConnection>::new(connspec);
    let pool = r2d2::Pool::builder().build(manager).expect("Failed to create pool.");

    HttpServer::new(move || {
        let static_path = utils::static_path();

        let storage = Storage::new();
        let queue = create_server(storage);

        WorkerConfig::new(|| ())
            .register::<WebmenentionSenderJob>()
            .register::<Picture>()
            .set_worker_count(DEFAULT_QUEUE, 1)
            .start_in_arbiter(&Arbiter::default(), queue.clone());

        App::new()
            .wrap(IdentityService::new(
{'fraction_non_alphanumeric': 0.14204983303365015, 'fraction_numerical': 0.0035961983046493705, 'mean_word_length': 5.01854714064915, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '5722248', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1258, 'n_words': 299}