chiark / gitweb /
New disorder-choose program for performing random selection.
[disorder] / server / disorderd.c
index 15e35727c46e82a34eba2590bce322f756f172cd..2fd317d05b9d54ca99ab756c5dd1389f81e47616 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder.
- * Copyright (C) 2004, 2005, 2006, 2007 Richard Kettlewell
+ * Copyright (C) 2004-2008 Richard Kettlewell
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -57,6 +57,7 @@
 #include "mixer.h"
 #include "eventlog.h"
 #include "printf.h"
+#include "version.h"
 
 static ev_source *ev;
 
@@ -93,13 +94,6 @@ static void help(void) {
   exit(0);
 }
 
-/* display version number and terminate */
-static void version(void) {
-  xprintf("%s", disorder_version_string);
-  xfclose(stdout);
-  exit(0);
-}
-
 /* SIGHUP callback */
 static int handle_sighup(ev_source attribute((unused)) *ev_,
                         int attribute((unused)) sig,
@@ -217,7 +211,7 @@ int main(int argc, char **argv) {
   while((n = getopt_long(argc, argv, "hVc:dfP:Ns", options, 0)) >= 0) {
     switch(n) {
     case 'h': help();
-    case 'V': version();
+    case 'V': version("disorderd");
     case 'c': configfile = optarg; break;
     case 'd': debugging = 1; break;
     case 'f': background = 0; break;
@@ -290,17 +284,10 @@ int main(int argc, char **argv) {
   if(ev_signal(ev, SIGTERM, handle_sigterm, 0)) fatal(0, "ev_signal failed");
   /* ignore SIGPIPE */
   signal(SIGPIPE, SIG_IGN);
-  /* Start a rescan straight away if this is a new installation.  This rescan
-   * blocks; the point is that when it is finished we are in a good position to
-   * choose a random track. */
-  if(!trackdb_existing_database) {
-    trackdb_rescan(0/*ev*/, 0/*check*/);
-    /* No ev -> the rescan will block.  Since we called reconfigure() already
-     * any clients will also be forced to block. */
-  }
-  /* Start a second rescan, with length checking enabled, immediately after
-   * startup. */
-  rescan_after(1);
+  /* Start a rescan straight away */
+  trackdb_rescan(ev, 1/*check*/);
+  /* We'll rescan again after a day */
+  rescan_after(86400);
   /* periodically tidy up the database */
   dbgc_after(60);
   /* periodically check the volume */