Support --logfile in nfs-proxy
parent
d03f19ebe5
commit
7142460ec8
|
@ -101,7 +101,7 @@ void epoll_manager_t::handle_uring_event()
|
||||||
my_uring_prep_poll_add(sqe, epoll_fd, POLLIN);
|
my_uring_prep_poll_add(sqe, epoll_fd, POLLIN);
|
||||||
data->callback = [this](ring_data_t *data)
|
data->callback = [this](ring_data_t *data)
|
||||||
{
|
{
|
||||||
if (data->res < 0)
|
if (data->res < 0 && data->res != -ECANCELED)
|
||||||
{
|
{
|
||||||
throw std::runtime_error(std::string("epoll failed: ") + strerror(-data->res));
|
throw std::runtime_error(std::string("epoll failed: ") + strerror(-data->res));
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,7 @@ public:
|
||||||
" Note that nbd_timeout, nbd_max_devices and nbd_max_part options may also be specified\n"
|
" Note that nbd_timeout, nbd_max_devices and nbd_max_part options may also be specified\n"
|
||||||
" in /etc/vitastor/vitastor.conf or in other configuration file specified with --config_file.\n"
|
" in /etc/vitastor/vitastor.conf or in other configuration file specified with --config_file.\n"
|
||||||
" --logfile /path/to/log/file.txt\n"
|
" --logfile /path/to/log/file.txt\n"
|
||||||
" Wite log messages to the specified file instead of dropping them (in background mode)\n"
|
" Write log messages to the specified file instead of dropping them (in background mode)\n"
|
||||||
" or printing them to the standard output (in foreground mode).\n"
|
" or printing them to the standard output (in foreground mode).\n"
|
||||||
" --dev_num N\n"
|
" --dev_num N\n"
|
||||||
" Use the specified device /dev/nbdN instead of automatic selection.\n"
|
" Use the specified device /dev/nbdN instead of automatic selection.\n"
|
||||||
|
@ -298,7 +298,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cfg["logfile"].is_string())
|
if (cfg["logfile"].string_value() != "")
|
||||||
{
|
{
|
||||||
logfile = cfg["logfile"].string_value();
|
logfile = cfg["logfile"].string_value();
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,7 @@ json11::Json::object nfs_proxy_t::parse_args(int narg, const char *args[])
|
||||||
" --nfspath <PATH> set NFS export path to <PATH> (default is /)\n"
|
" --nfspath <PATH> set NFS export path to <PATH> (default is /)\n"
|
||||||
" --port <PORT> use port <PORT> for NFS services (default is 2049)\n"
|
" --port <PORT> use port <PORT> for NFS services (default is 2049)\n"
|
||||||
" --pool <POOL> use <POOL> as default pool for new files (images)\n"
|
" --pool <POOL> use <POOL> as default pool for new files (images)\n"
|
||||||
|
" --logfile <FILE> log to the specified file\n"
|
||||||
" --foreground 1 stay in foreground, do not daemonize\n"
|
" --foreground 1 stay in foreground, do not daemonize\n"
|
||||||
"\n"
|
"\n"
|
||||||
"NFS proxy is stateless if you use immediate_commit=all in your cluster and if\n"
|
"NFS proxy is stateless if you use immediate_commit=all in your cluster and if\n"
|
||||||
|
@ -98,6 +99,8 @@ void nfs_proxy_t::run(json11::Json cfg)
|
||||||
srand48(tv.tv_sec*1000000000 + tv.tv_nsec);
|
srand48(tv.tv_sec*1000000000 + tv.tv_nsec);
|
||||||
server_id = (uint64_t)lrand48() | ((uint64_t)lrand48() << 31) | ((uint64_t)lrand48() << 62);
|
server_id = (uint64_t)lrand48() | ((uint64_t)lrand48() << 31) | ((uint64_t)lrand48() << 62);
|
||||||
// Parse options
|
// Parse options
|
||||||
|
if (cfg["logfile"].string_value() != "")
|
||||||
|
logfile = cfg["logfile"].string_value();
|
||||||
trace = cfg["log_level"].uint64_value() > 5 || cfg["trace"].uint64_value() > 0;
|
trace = cfg["log_level"].uint64_value() > 5 || cfg["trace"].uint64_value() > 0;
|
||||||
bind_address = cfg["bind"].string_value();
|
bind_address = cfg["bind"].string_value();
|
||||||
if (bind_address == "")
|
if (bind_address == "")
|
||||||
|
@ -999,8 +1002,8 @@ void nfs_proxy_t::daemonize()
|
||||||
close(1);
|
close(1);
|
||||||
close(2);
|
close(2);
|
||||||
open("/dev/null", O_RDONLY);
|
open("/dev/null", O_RDONLY);
|
||||||
open("/dev/null", O_WRONLY);
|
open(logfile.c_str(), O_WRONLY|O_APPEND|O_CREAT, 0666);
|
||||||
open("/dev/null", O_WRONLY);
|
open(logfile.c_str(), O_WRONLY|O_APPEND|O_CREAT, 0666);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int narg, const char *args[])
|
int main(int narg, const char *args[])
|
||||||
|
|
|
@ -33,6 +33,7 @@ public:
|
||||||
uint64_t fs_inode_count = 0;
|
uint64_t fs_inode_count = 0;
|
||||||
int readdir_getattr_parallel = 8, id_alloc_batch_size = 200;
|
int readdir_getattr_parallel = 8, id_alloc_batch_size = 200;
|
||||||
int trace = 0;
|
int trace = 0;
|
||||||
|
std::string logfile = "/dev/null";
|
||||||
|
|
||||||
pool_id_t default_pool_id;
|
pool_id_t default_pool_id;
|
||||||
uint64_t pool_block_size = 0;
|
uint64_t pool_block_size = 0;
|
||||||
|
|
Loading…
Reference in New Issue