28 LOG(
DEBUG) <<
"WsFsDaemonLoader::~WsFsDaemonLoader() : deleting this";
36 int nworkers = boost::lexical_cast<
int>(
m_props->
get(
"global",
"num_workers",
"1"));
56 cout <<
"Usage : " << endl;
57 cout <<
"[-h | --host] value\t: connect on host" << endl;
58 cout <<
"[-p | --port] value\t: connect on port" << endl;
59 cout <<
"[-w | --nworkers] value\t: number of workers" << endl;
60 cout <<
"[--protocol] value\t: use protocol" << endl;
61 cout <<
"[--daemonize]\t\t: run server in background" << endl;
62 cout <<
"[--root]\t\t: Filesystem root path" << endl;
63 cout <<
"[--help]\t\t: display this help message" << endl;
64 cout <<
"[--pid] value\t\t: write PID in file" << endl;
72 LOG(
INFO) <<
"WsFsDaemonLoader::handle_int() : Stopping server";
78 int main(
int argc,
char** argv)
86 static struct option long_options[] = {
87 {
"host", required_argument, NULL,
'h'},
88 {
"port", required_argument, NULL,
'p'},
89 {
"nworkers", required_argument, NULL,
'w'},
90 {
"daemonize", no_argument, NULL, 0},
91 {
"protocol", required_argument, NULL, 1},
92 {
"help", no_argument, NULL, 2},
93 {
"root", required_argument, NULL, 3},
94 {
"pid", required_argument, NULL, 4},
100 std::string pidPath =
"";
102 while ((c = getopt_long (argc, argv,
"h:p:w:01:", long_options, &option_index)) != -1) {
105 props->
set(
"global",
"host",
string((
char*)optarg));
108 props->
set(
"global",
"port",
string((
char*)optarg));
111 props->
set(
"global",
"num_workers",
string((
char*)optarg));
117 props->
set(
"global",
"protocol",
string((
char*)optarg));
123 props->
set(
"global",
"root_path",
string((
char*)optarg));
127 pidPath = string((
char*)optarg);
139 myfile.open (pidPath.c_str());
147 else return EXIT_FAILURE;
DaemonStatus bind(unsigned int numWorkers=1)
start listening on the port
int main(int argc, char **argv)
int daemonize()
daemonize the server, fork and put it in backgroud
static void handleSignal(int signum)
Loads the FsDaemon depending on the params passed as args.
Main class of the FsDaemon.
int start()
launch the server
bool m_daemon
daemonize or not
WsFsDaemonLoader * serverLoader
std::string get(const std::string §ion, const std::string &id, const std::string &def)
WsGlobalProperties * m_props
static WsGlobalProperties * instance()
WsFsDaemonLoader(WsGlobalProperties *props, bool daemon=false)
Constructor.
void set(const std::string §ion, std::string key, std::string value)
Changes or sets the propety with key 'key' to value 'value' If the property already exist...
~WsFsDaemonLoader()
destructor