Tweak logging

This commit is contained in:
Tony Garnock-Jones 2021-10-07 22:21:38 +02:00
parent e101258473
commit 3c42b5eaeb
5 changed files with 11 additions and 6 deletions

View File

@ -18,7 +18,7 @@ use syndicate_macros::during;
pub fn boot(t: &mut Activation, ds: Arc<Cap>) {
t.spawn(syndicate::name!("tracker", module = module_path!()), move |t| {
Ok(during!(t, ds, language(), <require-service $spec>, |t: &mut Activation| {
tracing::info!(?spec, "tracking dependencies");
tracing::debug!(?spec, "tracking dependencies");
t.spawn_link(syndicate::name!(parent: None, "tracker", spec = ?spec),
enclose!((ds) |t| run(t, ds, spec)));
Ok(())

View File

@ -36,7 +36,7 @@ pub fn on_demand(t: &mut Activation, config_ds: Arc<Cap>) {
Ok(during!(t, config_ds, language(), <run-service $spec: internal_services::ConfigWatcher>, |t| {
Supervisor::start(
t,
syndicate::name!(parent: None, "config", spec = ?spec),
syndicate::name!(parent: None, "config", path = ?spec.path),
SupervisorConfiguration::default(),
enclose!((config_ds, spec) lifecycle::updater(config_ds, spec)),
enclose!((config_ds) move |t| enclose!((config_ds, spec) run(t, config_ds, spec))))
@ -163,14 +163,17 @@ fn run(
let path = fs::canonicalize(spec.path.clone())?;
let env = script::Env::new(path, spec.env.0.clone());
tracing::info!("watching {:?}", &env.path);
tracing::info!(?env);
let (tx, rx) = channel();
let mut watcher = watcher(tx, Duration::from_millis(100)).map_err(convert_notify_error)?;
watcher.watch(&env.path, RecursiveMode::Recursive).map_err(convert_notify_error)?;
let facet = t.facet.clone();
let span = tracing::Span::current();
thread::spawn(move || {
let _entry = span.enter();
let mut path_state: Map<PathBuf, FacetId> = Map::new();
{

View File

@ -25,7 +25,7 @@ pub fn on_demand(t: &mut Activation, config_ds: Arc<Cap>, root_ds: Arc<Cap>) {
Ok(during!(t, config_ds, language(), <run-service $spec: DaemonService>, |t| {
Supervisor::start(
t,
syndicate::name!(parent: None, "daemon", service = ?spec),
syndicate::name!(parent: None, "daemon", id = ?spec.id),
SupervisorConfiguration::default(),
enclose!((config_ds, spec) lifecycle::updater(config_ds, spec)),
enclose!((config_ds, root_ds) move |t|

View File

@ -9,10 +9,12 @@ use crate::schemas::internal_services::Milestone;
use syndicate_macros::during;
pub fn on_demand(t: &mut Activation, ds: Arc<Cap>) {
t.spawn(syndicate::name!("on_demand", module = module_path!()), move |t| {
t.spawn(syndicate::name!("milestone"), move |t| {
Ok(during!(t, ds, language(), <run-service $spec: Milestone>, |t: &mut Activation| {
tracing::info!(milestone = ?spec.name, "entered");
ds.assert(t, language(), &lifecycle::started(&spec));
ds.assert(t, language(), &lifecycle::ready(&spec));
t.on_stop(move |_| { tracing::info!(milestone = ?spec.name, "exited"); Ok(()) });
Ok(())
}))
});

View File

@ -78,7 +78,7 @@ async fn bind_unix_listener(path: &PathBuf) -> Result<UnixListener, Error> {
Ok(_probe) => Err(e)?, // Someone's already there! Give up.
Err(f) if f.kind() == io::ErrorKind::ConnectionRefused => {
// Try to steal the socket.
tracing::info!("Cleaning stale socket");
tracing::debug!("Cleaning stale socket");
std::fs::remove_file(path)?;
Ok(UnixListener::bind(path)?)
}