mirror of
https://github.com/trapexit/mergerfs.git
synced 2026-11-21 07:26:28 -05:00
Add option to wait for branches to become new mounts
branches-mount-timeout=UINT64 in seconds (default: 0)
This commit is contained in:
parent
2d8d0f7ad6
commit
939eb3996a
14 changed files with 3034 additions and 106 deletions
|
|
@ -14,6 +14,9 @@
|
|||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "fs_wait_for_mount.hpp"
|
||||
#include "syslog.hpp"
|
||||
|
||||
#include "fs_path.hpp"
|
||||
#include "mergerfs.hpp"
|
||||
#include "option_parser.hpp"
|
||||
|
|
@ -147,6 +150,33 @@ namespace l
|
|||
resources::setpriority(prio);
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
wait_for_mount(const Config::Read &cfg_)
|
||||
{
|
||||
fs::PathVector paths;
|
||||
fs::PathVector failed;
|
||||
std::chrono::milliseconds timeout;
|
||||
|
||||
paths = cfg_->branches->to_paths();
|
||||
|
||||
syslog_info("Waiting %u seconds for branches to mount",
|
||||
(uint64_t)cfg_->branches_mount_timeout);
|
||||
|
||||
timeout = std::chrono::milliseconds(cfg_->branches_mount_timeout * 1000);
|
||||
fs::wait_for_mount((std::string)cfg_->mount,
|
||||
paths,
|
||||
timeout,
|
||||
failed);
|
||||
for(auto &path : failed)
|
||||
syslog_warning("Branch %s was not mounted within timeout",
|
||||
path.c_str());
|
||||
if(failed.size())
|
||||
syslog_warning("Continuing to mount mergerfs despite %u branches not "
|
||||
"being different from the mountpoint filesystem",
|
||||
failed.size());
|
||||
}
|
||||
|
||||
int
|
||||
main(const int argc_,
|
||||
char **argv_)
|
||||
|
|
@ -156,6 +186,8 @@ namespace l
|
|||
fuse_args args;
|
||||
fuse_operations ops;
|
||||
|
||||
syslog_open();
|
||||
|
||||
memset(&ops,0,sizeof(fuse_operations));
|
||||
|
||||
args.argc = argc_;
|
||||
|
|
@ -169,6 +201,9 @@ namespace l
|
|||
return 1;
|
||||
}
|
||||
|
||||
if(cfg->branches_mount_timeout > 0)
|
||||
l::wait_for_mount(cfg);
|
||||
|
||||
l::setup_resources();
|
||||
l::get_fuse_operations(ops,cfg->nullrw);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue