Commit 7ca75402 authored by Axel Auweter's avatar Axel Auweter
Browse files

Fix #32 (CollectAgent should support running as daemon)

parent 1dacb529
......@@ -122,11 +122,12 @@ void mqttCallback(SimpleMQTTMessage *msg)
* Print usage information
*/
void usage() {
printf("Usage: collectagent [-l <host>] [-h <host>]\n");
printf("Usage: collectagent [-D] [-l <host>] [-h <host>]\n");
printf("Collectagent will accept remote connections by listening to the\n");
printf("specified listen address (-l <host>) at port 1883 (default MQTT port).\n");
printf("It will also connect to cassandra to the specifiec addres (-h <host>).\n");
printf("The default <host> is localhost/127.0.0.1.\n\n");
printf("The default <host> is localhost/127.0.0.1.\n");
printf("If the -D option is specified, CollectAgent will run as daemon.\n\n");
}
int main(int argc, char* const argv[]) {
......@@ -148,7 +149,7 @@ int main(int argc, char* const argv[]) {
int ret;
listenHost="localhost";
cassandraHost="127.0.0.1";
while ((ret=getopt(argc, argv, "h:?"))!=-1) {
while ((ret=getopt(argc, argv, "h:l:D?"))!=-1) {
switch(ret) {
case 'h':
cassandraHost = optarg;
......@@ -156,6 +157,9 @@ int main(int argc, char* const argv[]) {
case 'l':
listenHost = optarg;
break;
case 'D':
daemon(1,1);
break;
case '?':
default:
usage();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment