-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add configuration option to disable lock file creation #1818
Add configuration option to disable lock file creation #1818
Conversation
Robot Results
Passed Tests
|
crates/core/tedge_mapper/src/main.rs
Outdated
// Run only one instance of a mapper (if enabled) | ||
if config.query(LockFilesSetting)?.is_set() { | ||
let run_dir: PathBuf = config.query(RunPathSetting)?.into(); | ||
let _flock = check_another_instance_is_not_running(&mapper_opt.name.to_string(), &run_dir)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the lock is released on drop, you have to use here the same trick as for the agent, i.e. to hold a reference to Some(Lock)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
crates/core/tedge_agent/src/agent.rs
Outdated
let config_repository = | ||
tedge_config::TEdgeConfigRepository::new(config.config_location.clone()); | ||
let tedge_config = config_repository.load()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor. Since the config is already read to populate the SmAgentConfig
, I wonder if one can simply extend the SmAgentConfig
struct with a use_lock
property that would be used here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense. I extended SmAgentConfig
and now it looks for this flag there.
crates/core/tedge_mapper/src/main.rs
Outdated
if config.query(LockFilesSetting)?.is_set() { | ||
let run_dir: PathBuf = config.query(RunPathSetting)?.into(); | ||
let _flock = Some(check_another_instance_is_not_running( | ||
&mapper_opt.name.to_string(), | ||
&run_dir, | ||
)?); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lock must stay in scope up to the end of main()
, as it would be released on drop.
if config.query(LockFilesSetting)?.is_set() { | |
let run_dir: PathBuf = config.query(RunPathSetting)?.into(); | |
let _flock = Some(check_another_instance_is_not_running( | |
&mapper_opt.name.to_string(), | |
&run_dir, | |
)?); | |
} | |
let mut flock = None; | |
if config.query(LockFilesSetting)?.is_set() { | |
let run_dir: PathBuf = config.query(RunPathSetting)?.into(); | |
flock = Some(check_another_instance_is_not_running( | |
&mapper_opt.name.to_string(), | |
&run_dir, | |
)?); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edited
51f0dd0
to
d3b2dae
Compare
b1e44bd
to
32eb57b
Compare
Signed-off-by: Krzysztof Piotrowski <krzysztof.piotrowski@inetum.com>
32eb57b
to
3dbe5d5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved. Thank you.
Proposed changes
This commit adds a configuration option to disable lock file creation by running the
tedge config
command or editing thetedge.toml
file. More information in #1802Types of changes
Paste Link to the issue
#1802
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments