Tweak logging
This commit is contained in:
parent
e101258473
commit
3c42b5eaeb
|
@ -18,7 +18,7 @@ use syndicate_macros::during;
|
||||||
pub fn boot(t: &mut Activation, ds: Arc<Cap>) {
|
pub fn boot(t: &mut Activation, ds: Arc<Cap>) {
|
||||||
t.spawn(syndicate::name!("tracker", module = module_path!()), move |t| {
|
t.spawn(syndicate::name!("tracker", module = module_path!()), move |t| {
|
||||||
Ok(during!(t, ds, language(), <require-service $spec>, |t: &mut Activation| {
|
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),
|
t.spawn_link(syndicate::name!(parent: None, "tracker", spec = ?spec),
|
||||||
enclose!((ds) |t| run(t, ds, spec)));
|
enclose!((ds) |t| run(t, ds, spec)));
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -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| {
|
Ok(during!(t, config_ds, language(), <run-service $spec: internal_services::ConfigWatcher>, |t| {
|
||||||
Supervisor::start(
|
Supervisor::start(
|
||||||
t,
|
t,
|
||||||
syndicate::name!(parent: None, "config", spec = ?spec),
|
syndicate::name!(parent: None, "config", path = ?spec.path),
|
||||||
SupervisorConfiguration::default(),
|
SupervisorConfiguration::default(),
|
||||||
enclose!((config_ds, spec) lifecycle::updater(config_ds, spec)),
|
enclose!((config_ds, spec) lifecycle::updater(config_ds, spec)),
|
||||||
enclose!((config_ds) move |t| enclose!((config_ds, spec) run(t, 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 path = fs::canonicalize(spec.path.clone())?;
|
||||||
let env = script::Env::new(path, spec.env.0.clone());
|
let env = script::Env::new(path, spec.env.0.clone());
|
||||||
|
|
||||||
tracing::info!("watching {:?}", &env.path);
|
tracing::info!(?env);
|
||||||
let (tx, rx) = channel();
|
let (tx, rx) = channel();
|
||||||
|
|
||||||
let mut watcher = watcher(tx, Duration::from_millis(100)).map_err(convert_notify_error)?;
|
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)?;
|
watcher.watch(&env.path, RecursiveMode::Recursive).map_err(convert_notify_error)?;
|
||||||
|
|
||||||
let facet = t.facet.clone();
|
let facet = t.facet.clone();
|
||||||
|
let span = tracing::Span::current();
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
|
let _entry = span.enter();
|
||||||
|
|
||||||
let mut path_state: Map<PathBuf, FacetId> = Map::new();
|
let mut path_state: Map<PathBuf, FacetId> = Map::new();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -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| {
|
Ok(during!(t, config_ds, language(), <run-service $spec: DaemonService>, |t| {
|
||||||
Supervisor::start(
|
Supervisor::start(
|
||||||
t,
|
t,
|
||||||
syndicate::name!(parent: None, "daemon", service = ?spec),
|
syndicate::name!(parent: None, "daemon", id = ?spec.id),
|
||||||
SupervisorConfiguration::default(),
|
SupervisorConfiguration::default(),
|
||||||
enclose!((config_ds, spec) lifecycle::updater(config_ds, spec)),
|
enclose!((config_ds, spec) lifecycle::updater(config_ds, spec)),
|
||||||
enclose!((config_ds, root_ds) move |t|
|
enclose!((config_ds, root_ds) move |t|
|
||||||
|
|
|
@ -9,10 +9,12 @@ use crate::schemas::internal_services::Milestone;
|
||||||
use syndicate_macros::during;
|
use syndicate_macros::during;
|
||||||
|
|
||||||
pub fn on_demand(t: &mut Activation, ds: Arc<Cap>) {
|
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| {
|
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::started(&spec));
|
||||||
ds.assert(t, language(), &lifecycle::ready(&spec));
|
ds.assert(t, language(), &lifecycle::ready(&spec));
|
||||||
|
t.on_stop(move |_| { tracing::info!(milestone = ?spec.name, "exited"); Ok(()) });
|
||||||
Ok(())
|
Ok(())
|
||||||
}))
|
}))
|
||||||
});
|
});
|
||||||
|
|
|
@ -78,7 +78,7 @@ async fn bind_unix_listener(path: &PathBuf) -> Result<UnixListener, Error> {
|
||||||
Ok(_probe) => Err(e)?, // Someone's already there! Give up.
|
Ok(_probe) => Err(e)?, // Someone's already there! Give up.
|
||||||
Err(f) if f.kind() == io::ErrorKind::ConnectionRefused => {
|
Err(f) if f.kind() == io::ErrorKind::ConnectionRefused => {
|
||||||
// Try to steal the socket.
|
// Try to steal the socket.
|
||||||
tracing::info!("Cleaning stale socket");
|
tracing::debug!("Cleaning stale socket");
|
||||||
std::fs::remove_file(path)?;
|
std::fs::remove_file(path)?;
|
||||||
Ok(UnixListener::bind(path)?)
|
Ok(UnixListener::bind(path)?)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue