aboutsummaryrefslogtreecommitdiff
path: root/src/arm/gnunet-service-arm.c
blob: ac58904ed95f74808fb0b96aea669bd1258daaa0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
/*
     This file is part of GNUnet.
     (C) 2009 Christian Grothoff (and other contributing authors)

     GNUnet is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published
     by the Free Software Foundation; either version 2, or (at your
     option) any later version.

     GNUnet is distributed in the hope that it will be useful, but
     WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     General Public License for more details.

     You should have received a copy of the GNU General Public License
     along with GNUnet; see the file COPYING.  If not, write to the
     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
     Boston, MA 02111-1307, USA.
*/

/**
 * @file arm/gnunet-service-arm.c
 * @brief the automated restart manager service
 * @author Christian Grothoff
 *
 * TODO:
 * - multiple start-stop requests with RC>1 can result
 *   in UP/DOWN signals based on "pending" that are inaccurate...
 *   => have list of clients waiting for a resolution instead of
 *      giving instant (but incorrect) replies
 * - code could go into restart-loop for a service
 *   if service crashes instantly -- need exponential back-off
 * - need to test auto-restart code on configuration changes;
 * - should refine restart code to check if *relevant* parts of the
 *   configuration were changed (anything in the section for the service)
 * - should have a way to specify dependencies between services and
 *   manage restarts of groups of services
 */
#include "platform.h"
#include "gnunet_client_lib.h"
#include "gnunet_getopt_lib.h"
#include "gnunet_os_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_service_lib.h"
#include "arm.h"


/**
 * Run maintenance every second.
 */
#define MAINT_FREQUENCY GNUNET_TIME_UNIT_SECONDS

/**
 * How long do we wait until we decide that a service
 * did not start?
 */
#define CHECK_TIMEOUT GNUNET_TIME_UNIT_MINUTES

struct ServiceList;

typedef void (*CleanCallback) (void *cls, struct ServiceList * pos);

/**
 * List of our services.
 */
struct ServiceList
{
  /**
   * This is a linked list.
   */
  struct ServiceList *next;

  /**
   * Name of the service.
   */
  char *name;

  /**
   * Name of the binary used.
   */
  char *binary;

  /**
   * Name of the configuration file used.
   */
  char *config;

  /**
   * Function to call upon kill completion (waitpid), NULL
   * if we should simply restart the process.
   */
  CleanCallback kill_continuation;

  /**
   * Closure for kill_continuation.
   */
  void *kill_continuation_cls;

  /**
   * Process ID of the child.
   */
  pid_t pid;

  /**
   * Last time the config of this service was
   * modified.
   */
  time_t mtime;

  /**
   * Reference counter (counts how many times we've been
   * asked to start the service).  We only actually stop
   * it once rc hits zero.
   */
  unsigned int rc;

};

/**
 * List of running services.
 */
static struct ServiceList *running;

/**
 * Our configuration
 */
static const struct GNUNET_CONFIGURATION_Handle *cfg;

/**
 * Our scheduler.
 */
static struct GNUNET_SCHEDULER_Handle *sched;

/**
 * Command to prepend to each actual command.
 */
static char *prefix_command;


static size_t
write_result (void *cls, size_t size, void *buf)
{
  uint16_t *res = cls;
  struct GNUNET_MessageHeader *msg;

  if (buf == NULL)
    return 0;                   /* error, not much we can do */
  GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader));
  msg = buf;
  msg->size = htons (sizeof (struct GNUNET_MessageHeader));
  msg->type = htons (*res);
  GNUNET_free (res);
  return sizeof (struct GNUNET_MessageHeader);
}



/**
 * Signal our client that we will start or stop the
 * service.
 *
 * @return NULL if it was not found
 */
static void
signal_result (struct GNUNET_SERVER_Client *client,
               const char *name, uint16_t result)
{
  uint16_t *res;

  if (NULL == client)
    return;
#if DEBUG_ARM
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Telling client that service `%s' is now %s\n",
              name,
              result == GNUNET_MESSAGE_TYPE_ARM_IS_DOWN ? "down" : "up");
#endif
  res = GNUNET_malloc (sizeof (uint16_t));
  *res = result;
  GNUNET_SERVER_notify_transmit_ready (client,
                                       sizeof (struct GNUNET_MessageHeader),
                                       GNUNET_TIME_UNIT_FOREVER_REL,
                                       &write_result, res);
}


/**
 * Find the process with the given service
 * name in the given list, remove it and return it.
 *
 * @return NULL if it was not found
 */
static struct ServiceList *
find_name (const char *name)
{
  struct ServiceList *pos;
  struct ServiceList *prev;

  pos = running;
  prev = NULL;
  while (pos != NULL)
    {
      if (0 == strcmp (pos->name, name))
        {
          if (prev == NULL)
            running = pos->next;
          else
            prev->next = pos->next;
          pos->next = NULL;
          return pos;
        }
      prev = pos;
      pos = pos->next;
    }
  return NULL;
}


static void
free_entry (struct ServiceList *pos)
{
  GNUNET_free_non_null (pos->config);
  GNUNET_free_non_null (pos->binary);
  GNUNET_free (pos->name);
  GNUNET_free (pos);
}




/**
 * Actually start the process for the given service.
 *
 * @param sl identifies service to start
 */
static void
start_process (struct ServiceList *sl)
{
  char *loprefix;
  char *options;
  char **argv;
  unsigned int argv_size;
  char *lopos;
  char *optpos;
  const char *firstarg;
  int use_debug;

  /* start service */
  if (GNUNET_OK !=
      GNUNET_CONFIGURATION_get_value_string (cfg,
                                             sl->name, "PREFIX", &loprefix))
    loprefix = GNUNET_strdup (prefix_command);
  if (GNUNET_OK !=
      GNUNET_CONFIGURATION_get_value_string (cfg,
                                             sl->name, "OPTIONS", &options))
    options = GNUNET_strdup ("");
  use_debug = GNUNET_CONFIGURATION_get_value_yesno (cfg, sl->name, "DEBUG");

  GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Starting service `%s'\n"), sl->name);
#if DEBUG_ARM
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Starting service `%s' using binary `%s' and configuration `%s'\n",
              sl->name, sl->binary, sl->config);
#endif
  argv_size = 6;
  if (use_debug)
    argv_size += 2;
  lopos = loprefix;
  while ('\0' != *lopos)
    {
      if (*lopos == ' ')
        argv_size++;
      lopos++;
    }
  optpos = options;
  while ('\0' != *optpos)
    {
      if (*optpos == ' ')
        argv_size++;
      optpos++;
    }
  firstarg = NULL;
  argv = GNUNET_malloc (argv_size * sizeof (char *));
  argv_size = 0;
  lopos = loprefix;

  while ('\0' != *lopos)
    {
      while (*lopos == ' ')
        lopos++;
      if (*lopos == '\0')
        continue;
      if (argv_size == 0)
        firstarg = lopos;
      argv[argv_size++] = lopos;
      while (('\0' != *lopos) && (' ' != *lopos))
        lopos++;
      if ('\0' == *lopos)
        continue;
      *lopos = '\0';
      lopos++;
    }
  if (argv_size == 0)
    firstarg = sl->binary;
  argv[argv_size++] = sl->binary;
  argv[argv_size++] = "-c";
  argv[argv_size++] = sl->config;
  if (GNUNET_YES == use_debug)
    {
      argv[argv_size++] = "-L";
      argv[argv_size++] = "DEBUG";
    }
  optpos = options;
  while ('\0' != *optpos)
    {
      while (*optpos == ' ')
        optpos++;
      if (*optpos == '\0')
        continue;
      argv[argv_size++] = optpos;
      while (('\0' != *optpos) && (' ' != *optpos))
        optpos++;
      if ('\0' == *optpos)
        continue;
      *optpos = '\0';
      optpos++;
    }
  argv[argv_size++] = NULL;
  sl->pid = GNUNET_OS_start_process_v (firstarg, argv);
  GNUNET_free (argv);
  GNUNET_free (loprefix);
  GNUNET_free (options);
}


/**
 * Start the specified service.
 */
static void
start_service (struct GNUNET_SERVER_Client *client, const char *servicename)
{
  struct ServiceList *sl;
  char *binary;
  char *config;
  struct stat sbuf;
  sl = find_name (servicename);
  if (sl != NULL)
    {
      /* already running, just increment RC */
      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                  _("Service `%s' already running.\n"), servicename);
      sl->rc++;
      sl->next = running;
      running = sl;
      signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_UP);
      return;
    }
  if (GNUNET_OK !=
      GNUNET_CONFIGURATION_get_value_string (cfg,
                                             servicename, "BINARY", &binary))
    {
      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                  _("Binary implementing service `%s' not known!\n"),
                  servicename);
      signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN);
      return;
    }
  if ((GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_filename (cfg,
                                                servicename,
                                                "CONFIG",
                                                &config)) ||
      (0 != STAT (config, &sbuf)))
    {
      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                  _("Configuration file `%s' for service `%s' not known!\n"),
                  config, servicename);
      signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN);
      GNUNET_free (binary);
      GNUNET_free (config);
      return;
    }
  sl = GNUNET_malloc (sizeof (struct ServiceList));
  sl->name = GNUNET_strdup (servicename);
  sl->next = running;
  sl->rc = 1;
  sl->binary = binary;
  sl->config = config;
  sl->mtime = sbuf.st_mtime;
  running = sl;
  start_process (sl);
  if (NULL != client)
    signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_UP);
}


static void
free_and_signal (void *cls, struct ServiceList *pos)
{
  struct GNUNET_SERVER_Client *client = cls;
  /* find_name will remove "pos" from the list! */
  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Service `%s' stopped\n", pos->name);
  signal_result (client, pos->name, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN);
  GNUNET_SERVER_receive_done (client, GNUNET_OK);
  GNUNET_SERVER_client_drop (client);
  free_entry (pos);
}


/**
 * Stop the specified service.
 */
static void
stop_service (struct GNUNET_SERVER_Client *client, const char *servicename)
{
  struct ServiceList *pos;
  struct GNUNET_CLIENT_Connection *sc;
  unsigned long long port;

  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
              "Preparing to stop `%s'\n", servicename);
  pos = find_name (servicename);
  if ((pos != NULL) && (pos->kill_continuation != NULL))
    {
      /* killing already in progress */
      signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN);
      return;
    }
  if ((pos != NULL) && (pos->rc > 1))
    {
      /* RC>1, just decrement RC */
      pos->rc--;
      pos->next = running;
      running = pos;
      signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_UP);
      GNUNET_SERVER_receive_done (client, GNUNET_OK);
      return;
    }
  if (pos != NULL)
    {
      if (0 != PLIBC_KILL (pos->pid, SIGTERM))
        GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
      pos->next = running;
      running = pos;
      pos->kill_continuation = &free_and_signal;
      pos->kill_continuation_cls = client;
      GNUNET_SERVER_client_keep (client);
    }
  else
    {
      if ( (GNUNET_OK ==
	    GNUNET_CONFIGURATION_get_value_number (cfg,
						   servicename,
						   "PORT",
						   &port)) &&
	   (NULL != (sc = GNUNET_CLIENT_connect (sched, servicename, cfg))) )
	{
	  GNUNET_CLIENT_service_shutdown (sc);
	  GNUNET_CLIENT_disconnect (sc);
	  signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN);
	}
      else
	{
	  signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_UNKNOWN);
	}
      GNUNET_SERVER_receive_done (client, GNUNET_OK);
    }
}


/**
 * Handle START-message.
 *
 * @param cls closure (always NULL)
 * @param client identification of the client
 * @param message the actual message
 * @return GNUNET_OK to keep the connection open,
 *         GNUNET_SYSERR to close it (signal serious error)
 */
static void
handle_start (void *cls,
              struct GNUNET_SERVER_Client *client,
              const struct GNUNET_MessageHeader *message)
{
  const char *servicename;
  uint16_t size;

  size = ntohs (message->size);
  size -= sizeof (struct GNUNET_MessageHeader);
  servicename = (const char *) &message[1];
  if ((size == 0) || (servicename[size - 1] != '\0'))
    {
      GNUNET_break (0);
      GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
      return;
    }
  start_service (client, servicename);
  GNUNET_SERVER_receive_done (client, GNUNET_OK);
}


/**
 * Handle STOP-message.
 *
 * @param cls closure (always NULL)
 * @param client identification of the client
 * @param message the actual message
 * @return GNUNET_OK to keep the connection open,
 *         GNUNET_SYSERR to close it (signal serious error)
 */
static void
handle_stop (void *cls,
             struct GNUNET_SERVER_Client *client,
             const struct GNUNET_MessageHeader *message)
{
  const char *servicename;
  uint16_t size;

  size = ntohs (message->size);
  size -= sizeof (struct GNUNET_MessageHeader);
  servicename = (const char *) &message[1];
  if ((size == 0) || (servicename[size - 1] != '\0'))
    {
      GNUNET_break (0);
      GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
      return;
    }
  stop_service (client, servicename);
}



/**
 * Background task doing maintenance.
 *
 * @param cls closure
 * @param tc context
 */
static void
maint (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
  struct ServiceList *pos;
  struct ServiceList *prev;
  struct ServiceList *next;
  const char *statstr;
  int statcode;
  struct stat sbuf;
  int ret;

  if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
    {
      GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Stopping all services\n"));
      while (NULL != (pos = running))
        {
          running = pos->next;
          if (0 != PLIBC_KILL (pos->pid, SIGTERM))
            GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
          if (GNUNET_OK != GNUNET_OS_process_wait(pos->pid))
            GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
          free_entry (pos);
        }
      return;
    }
  GNUNET_SCHEDULER_add_delayed (tc->sched,
                                GNUNET_YES,
                                GNUNET_SCHEDULER_PRIORITY_IDLE,
                                GNUNET_SCHEDULER_NO_TASK,
                                MAINT_FREQUENCY, &maint, NULL);

  /* check for services that died (WAITPID) */
  prev = NULL;
  next = running;
  while (NULL != (pos = next))
    {
      enum GNUNET_OS_ProcessStatusType statusType;
      unsigned long statusCode;
     
      next = pos->next;
      if (pos->pid == 0)
	{
	  if (NULL != pos->kill_continuation)
	    {
	      if (prev == NULL)
		running = next;
	      else
		prev->next = next;
	      pos->kill_continuation (pos->kill_continuation_cls, pos);	    
	    }
	  continue;
	}
      if ( (GNUNET_SYSERR == (ret = GNUNET_OS_process_status(pos->pid, 
							     &statusType,
							     &statusCode))) ||
	   ( (ret == GNUNET_NO) ||
	     (statusType == GNUNET_OS_PROCESS_STOPPED) || 
	     (statusType == GNUNET_OS_PROCESS_RUNNING) ) )
	{
	  prev = pos;
	  continue;
	}
      if (statusType == GNUNET_OS_PROCESS_EXITED)
	{
	  statstr = _( /* process termination method */ "exit");
	  statcode = statusCode;
	}
      else if (statusType == GNUNET_OS_PROCESS_SIGNALED)
	{
	  statstr = _( /* process termination method */ "signal");
	  statcode = statusCode;
	}
      else
	{
	  statstr = _( /* process termination method */ "unknown");
	  statcode = 0;
	}    
      if (NULL != pos->kill_continuation)
        {
	  if (prev == NULL)
	    running = next;
	  else
	    prev->next = next;
	  pos->kill_continuation (pos->kill_continuation_cls, pos);
	  continue;
        }
      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
		  _("Service `%s' terminated with status %s/%d, will try to restart it!\n"),
		  pos->name, statstr, statcode);
      /* schedule restart */
      pos->pid = 0;
      prev = pos;
    }

  /* check for services that need to be restarted due to
     configuration changes or because the last restart failed */
  pos = running;
  while (pos != NULL)
    {
      if ((0 == STAT (pos->config, &sbuf)) && (pos->mtime < sbuf.st_mtime))
        {
          GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                      _("Restarting service `%s' due to configuration file change.\n"));
          if (0 != PLIBC_KILL (pos->pid, SIGTERM))
            GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
        }
      if (pos->pid == 0)
        {
          GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                      _("Restarting service `%s'.\n"), pos->name);
          /* FIXME: should have some exponentially
             increasing timer to avoid tight restart loops */
          start_process (pos);
        }
      pos = pos->next;
    }
}


/**
 * List of handlers for the messages understood by this
 * service.
 */
static struct GNUNET_SERVER_MessageHandler handlers[] = {
  {&handle_start, NULL, GNUNET_MESSAGE_TYPE_ARM_START, 0},
  {&handle_stop, NULL, GNUNET_MESSAGE_TYPE_ARM_STOP, 0},
  {NULL, NULL, 0, 0}
};


/**
 * Process arm requests.
 *
 * @param cls closure
 * @param s scheduler to use
 * @param server the initialized server
 * @param c configuration to use
 */
static void
run (void *cls,
     struct GNUNET_SCHEDULER_Handle *s,
     struct GNUNET_SERVER_Handle *server,
     const struct GNUNET_CONFIGURATION_Handle *c)
{
  char *defaultservices;
  char *pos;

  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Starting...\n");
  cfg = c;
  sched = s;
  if (GNUNET_OK !=
      GNUNET_CONFIGURATION_get_value_string (cfg,
                                             "ARM",
                                             "GLOBAL_PREFIX",
                                             &prefix_command))
    prefix_command = GNUNET_strdup ("");
  /* start default services... */
  if (GNUNET_OK ==
      GNUNET_CONFIGURATION_get_value_string (cfg,
                                             "ARM",
                                             "DEFAULTSERVICES",
                                             &defaultservices))
    {
#if DEBUG_ARM
      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                  "Starting default services `%s'\n", defaultservices);
#endif
      pos = strtok (defaultservices, " ");
      while (pos != NULL)
        {
          start_service (NULL, pos);
          pos = strtok (NULL, " ");
        }
      GNUNET_free (defaultservices);
    }
  else
    {
#if DEBUG_ARM
      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                  "No default services configured.\n");
#endif
    }

  /* process client requests */
  GNUNET_SERVER_add_handlers (server, handlers);

  /* manage services */
  GNUNET_SCHEDULER_add_delayed (sched,
                                GNUNET_YES,
                                GNUNET_SCHEDULER_PRIORITY_IDLE,
                                GNUNET_SCHEDULER_NO_TASK,
                                MAINT_FREQUENCY, &maint, NULL);
}


/**
 * The main function for the arm service.
 *
 * @param argc number of arguments from the command line
 * @param argv command line arguments
 * @return 0 ok, 1 on error
 */
int
main (int argc, char *const *argv)
{
  return (GNUNET_OK ==
          GNUNET_SERVICE_run (argc,
                              argv, "arm", &run, NULL, NULL, NULL)) ? 0 : 1;
}

/* end of gnunet-service-arm.c */