WIP: server: ???

This commit is contained in:
Paul Campbell 2024-06-19 07:03:17 +01:00
parent 2cf21c11fc
commit 4c0513cafb
3 changed files with 14 additions and 13 deletions

View file

@ -716,7 +716,7 @@ pub mod given {
pub fn a_git_dir(fs: &kxio::fs::FileSystem) -> GitDir {
let dir_name = a_name();
let dir = fs.base().join(dir_name);
GitDir::new(&dir)
GitDir::new(dir)
}
pub fn a_forge_config() -> ForgeConfig {

View file

@ -8,7 +8,7 @@ use git_next_config::{
self as config, ForgeAlias, ForgeConfig, GitDir, RepoAlias, ServerRepoConfig,
};
use git_next_git::{Generation, RepoDetails, Repository};
use git_next_repo_actor::{messages::CloneRepo, RepoActor};
use git_next_repo_actor as repo_actor;
use kxio::{fs::FileSystem, network::Network};
use tracing::{error, info, warn};
@ -158,7 +158,7 @@ impl Server {
forge_name: ForgeAlias,
server_storage: &ServerStorage,
webhook: &Webhook,
) -> Vec<(ForgeAlias, RepoAlias, RepoActor)> {
) -> Vec<(ForgeAlias, RepoAlias, repo_actor::RepoActor)> {
let span =
tracing::info_span!("create_forge_repos", name = %forge_name, config = %forge_config);
@ -183,13 +183,14 @@ impl Server {
forge_config: ForgeConfig,
server_storage: &ServerStorage,
webhook: &Webhook,
) -> impl Fn((RepoAlias, &ServerRepoConfig)) -> (ForgeAlias, RepoAlias, RepoActor) {
) -> impl Fn((RepoAlias, &ServerRepoConfig)) -> (ForgeAlias, RepoAlias, repo_actor::RepoActor)
{
let server_storage = server_storage.clone();
let webhook = webhook.clone();
let net = self.net.clone();
let repo = self.repo.clone();
let generation = self.generation;
let sleep_duration = self.sleep_duration.clone();
let sleep_duration = self.sleep_duration;
move |(repo_alias, server_repo_config)| {
let span = tracing::info_span!("create_actor", alias = %repo_alias, config = %server_repo_config);
let _guard = span.enter();
@ -216,7 +217,7 @@ impl Server {
gitdir,
);
info!("Starting Repo Actor");
let actor = RepoActor::new(
let actor = repo_actor::RepoActor::new(
repo_details,
webhook.clone(),
generation,
@ -230,13 +231,13 @@ impl Server {
fn start_actor(
&self,
actor: (ForgeAlias, RepoAlias, RepoActor),
) -> (RepoAlias, Addr<RepoActor>) {
actor: (ForgeAlias, RepoAlias, repo_actor::RepoActor),
) -> (RepoAlias, Addr<repo_actor::RepoActor>) {
let (forge_name, repo_alias, actor) = actor;
let span = tracing::info_span!("start_actor", forge = %forge_name, repo = %repo_alias);
let _guard = span.enter();
let addr = actor.start();
addr.do_send(CloneRepo);
addr.do_send(repo_actor::messages::CloneRepo);
info!("Started");
(repo_alias, addr)
}

View file

@ -1,19 +1,18 @@
//
mod actors;
mod config;
//
use actix::prelude::*;
use git_next_git::Repository;
use kxio::{fs::FileSystem, network::Network};
use std::path::PathBuf;
use tracing::{error, info, level_filters::LevelFilter};
use crate::actors::{
file_watcher::{self, FileUpdated},
server::Server,
};
use git_next_git::Repository;
pub fn init(fs: FileSystem) {
let file_name = "git-next-server.toml";
@ -63,6 +62,7 @@ pub async fn start(
info!("Server running - Press Ctrl-C to stop...");
let _ = actix_rt::signal::ctrl_c().await;
info!("Ctrl-C received, shutting down...");
// TODO: (#94) perform a controlled shutdown of server and file watcher
}
pub fn init_logging() {