As asked by Sergio Ballestreros, adding TS_SLOTS to set the default amount of
authorviric@vicerveza
Tue, 12 Aug 2008 12:57:40 +0200
changeset 239 18301d7a56d4
parent 238 d490cad20a00
child 240 9ecdf06ddf5d
child 271 11e4c2ac9607
As asked by Sergio Ballestreros, adding TS_SLOTS to set the default amount of slots at server start time.
main.c
server.c
--- a/main.c	Tue Aug 12 12:50:43 2008 +0200
+++ b/main.c	Tue Aug 12 12:57:40 2008 +0200
@@ -311,6 +311,7 @@
     printf("  TS_ONFINISH  binary called on job end (passes jobid, error, outfile, command).\n");
     printf("  TS_ENV  command called on enqueue. Its output determines the job information.\n");
     printf("  TS_SAVELIST  filename which will store the list, if the server dies.\n");
+    printf("  TS_SLOTS   amount of jobs which can run at once, read on server start.\n");
     printf("Actions:\n");
     printf("  -K       kill the task spooler server\n");
     printf("  -C       clear the list of finished jobs\n");
--- a/server.c	Tue Aug 12 12:50:43 2008 +0200
+++ b/server.c	Tue Aug 12 12:57:40 2008 +0200
@@ -80,6 +80,19 @@
     exit(1);
 }
 
+static void set_default_maxslots()
+{
+    char *str;
+
+    str = getenv("TS_SLOTS");
+    if (str != NULL)
+    {
+        int slots;
+        slots = abs(atoi(str));
+        s_set_max_slots(slots);
+    }
+}
+
 static void install_sigterm_handler()
 {
   struct sigaction act;
@@ -151,6 +164,8 @@
 
     install_sigterm_handler();
 
+    set_default_maxslots();
+
     notify_parent(notify_fd);
 
     server_loop(ls);