1- use std:: { collections:: HashSet , future:: Future , path:: Path , pin:: Pin } ;
1+ use std:: {
2+ collections:: HashSet ,
3+ future:: Future ,
4+ path:: { Path , PathBuf } ,
5+ pin:: Pin ,
6+ } ;
27
38use log:: info;
49use spin_app:: { locked:: LockedApp , App } ;
510use spin_runtime_factors:: { FactorsBuilder , TriggerFactors } ;
611use spin_trigger:: {
7- cli:: { FactorsConfig , TriggerAppBuilder } ,
12+ cli:: { FactorsConfig , TriggerAppBuilder , UserProvidedPath } ,
813 loader:: ComponentLoader ,
914 Trigger ,
1015} ;
@@ -14,7 +19,7 @@ use trigger_command::CommandTrigger;
1419use trigger_mqtt:: MqttTrigger ;
1520use trigger_sqs:: SqsTrigger ;
1621
17- use crate :: constants:: { RUNTIME_CONFIG_PATH , SPIN_TRIGGER_WORKING_DIR } ;
22+ use crate :: constants:: { RUNTIME_CONFIG_PATH , SPIN_DEFAULT_STATE_DIR , SPIN_TRIGGER_WORKING_DIR } ;
1823
1924pub ( crate ) const HTTP_TRIGGER_TYPE : & str = <HttpTrigger as Trigger < TriggerFactors > >:: TYPE ;
2025pub ( crate ) const REDIS_TRIGGER_TYPE : & str = <RedisTrigger as Trigger < TriggerFactors > >:: TYPE ;
@@ -47,9 +52,16 @@ fn factors_config() -> FactorsConfig {
4752 let runtime_config_file = Path :: new ( RUNTIME_CONFIG_PATH )
4853 . exists ( )
4954 . then ( || RUNTIME_CONFIG_PATH . into ( ) ) ;
55+ // Configure the application state directory path. This is used in the default
56+ // locations for logs, key value stores, etc.
57+ let state_dir = PathBuf :: from ( SPIN_TRIGGER_WORKING_DIR ) . join ( SPIN_DEFAULT_STATE_DIR ) ;
5058 FactorsConfig {
5159 working_dir : SPIN_TRIGGER_WORKING_DIR . into ( ) ,
5260 runtime_config_file,
61+ state_dir : UserProvidedPath :: Provided ( state_dir) ,
62+ // Explicitly do not set log dir in order to force logs to be displayed to stdout.
63+ // Otherwise, would default to the state directory.
64+ log_dir : UserProvidedPath :: Unset ,
5365 ..Default :: default ( )
5466 }
5567}
0 commit comments