Support --logfile in nfs-proxy
Test / buildenv (push) Successful in 9s Details
Test / build (push) Successful in 3m6s Details
Test / test_cas (push) Successful in 7s Details
Test / make_test (push) Successful in 34s Details
Test / test_change_pg_count (push) Successful in 33s Details
Test / test_change_pg_size (push) Successful in 6s Details
Test / test_change_pg_count_ec (push) Successful in 33s Details
Test / test_create_nomaxid (push) Successful in 6s Details
Test / test_etcd_fail (push) Successful in 47s Details
Test / test_interrupted_rebalance_imm (push) Successful in 1m47s Details
Test / test_add_osd (push) Successful in 2m36s Details
Test / test_failure_domain (push) Successful in 42s Details
Test / test_interrupted_rebalance_ec (push) Successful in 2m2s Details
Test / test_interrupted_rebalance (push) Successful in 2m47s Details
Test / test_snapshot (push) Successful in 20s Details
Test / test_minsize_1 (push) Successful in 14s Details
Test / test_interrupted_rebalance_ec_imm (push) Successful in 1m22s Details
Test / test_snapshot_ec (push) Successful in 27s Details
Test / test_move_reappear (push) Successful in 19s Details
Test / test_rm (push) Successful in 13s Details
Test / test_snapshot_down (push) Successful in 22s Details
Test / test_snapshot_down_ec (push) Successful in 28s Details
Test / test_splitbrain (push) Successful in 28s Details
Test / test_snapshot_chain (push) Successful in 2m18s Details
Test / test_snapshot_chain_ec (push) Successful in 3m3s Details
Test / test_rebalance_verify_imm (push) Successful in 3m18s Details
Test / test_rebalance_verify (push) Successful in 3m54s Details
Test / test_switch_primary (push) Successful in 33s Details
Test / test_write (push) Successful in 52s Details
Test / test_write_no_same (push) Successful in 13s Details
Test / test_write_xor (push) Successful in 51s Details
Test / test_rebalance_verify_ec (push) Has started running Details
Test / test_rebalance_verify_ec_imm (push) Has started running Details
Test / test_heal_pg_size_2 (push) Has started running Details
Test / test_heal_csum_32k_dmj (push) Has been cancelled Details
Test / test_heal_csum_32k_dj (push) Has been cancelled Details
Test / test_heal_csum_32k (push) Has been cancelled Details
Test / test_heal_csum_4k_dmj (push) Has been cancelled Details
Test / test_heal_csum_4k_dj (push) Has been cancelled Details
Test / test_heal_csum_4k (push) Has been cancelled Details
Test / test_scrub (push) Has been cancelled Details
Test / test_scrub_zero_osd_2 (push) Has been cancelled Details
Test / test_scrub_xor (push) Has been cancelled Details
Test / test_scrub_pg_size_3 (push) Has been cancelled Details
Test / test_scrub_pg_size_6_pg_minsize_4_osd_count_6_ec (push) Has been cancelled Details
Test / test_scrub_ec (push) Has been cancelled Details
Test / test_nfs (push) Has been cancelled Details
Test / test_heal_ec (push) Has been cancelled Details

Vitaliy Filippov 2024-03-03 13:50:35 +03:00
parent f197544463
commit 1f77f1ebce
3 changed files with 10 additions and 4 deletions

View File

@ -146,7 +146,7 @@ public:
" 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"
" --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"
" --dev_num N\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();
}

View File

@ -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"
" --port <PORT> use port <PORT> for NFS services (default is 2049)\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"
"\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);
server_id = (uint64_t)lrand48() | ((uint64_t)lrand48() << 31) | ((uint64_t)lrand48() << 62);
// Parse options
if (cfg["logfile"].string_value() != "")
logfile = cfg["logfile"].string_value();
trace = cfg["log_level"].uint64_value() > 5 || cfg["trace"].uint64_value() > 0;
bind_address = cfg["bind"].string_value();
if (bind_address == "")
@ -999,8 +1002,10 @@ void nfs_proxy_t::daemonize()
close(1);
close(2);
open("/dev/null", O_RDONLY);
open("/dev/null", O_WRONLY);
open("/dev/null", O_WRONLY);
open(logfile.c_str(), O_WRONLY|O_APPEND|O_CREAT, 0666);
open(logfile.c_str(), O_WRONLY|O_APPEND|O_CREAT, 0666);
if (chdir("/") != 0)
fprintf(stderr, "Warning: Failed to chdir into /\n");
}
int main(int narg, const char *args[])

View File

@ -33,6 +33,7 @@ public:
uint64_t fs_inode_count = 0;
int readdir_getattr_parallel = 8, id_alloc_batch_size = 200;
int trace = 0;
std::string logfile = "/dev/null";
pool_id_t default_pool_id;
uint64_t pool_block_size = 0;