REST: trigger start; fix port
authorSchanzenbach, Martin <mschanzenbach@posteo.de>
Mon, 29 Apr 2019 06:06:44 +0000 (08:06 +0200)
committerSchanzenbach, Martin <mschanzenbach@posteo.de>
Mon, 29 Apr 2019 06:06:44 +0000 (08:06 +0200)
src/rest/gnunet-rest-server.c
src/rest/rest.conf

index 3cbb750bacd83c2e3fae073c0c064f56c575a3d0..8135254049de774fa6a09d24e7f1834c3c169e9f 100644 (file)
@@ -11,7 +11,7 @@
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Affero General Public License for more details.
-  
+
    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
@@ -597,7 +597,7 @@ schedule_httpd ()
       GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT,
                                    tv, wrs, wws,
                                    &do_httpd, NULL);
-    
+
   }
   if (NULL != wrs)
     GNUNET_NETWORK_fdset_destroy (wrs);
@@ -822,6 +822,18 @@ run (void *cls,
   cfg = c;
   plugin_map = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO);
 
+  /* Get port to bind to */
+  if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "rest",
+                                                          "PORT",
+                                                          &port))
+  {
+    //No address specified
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Don't know what port to use...\n");
+    GNUNET_SCHEDULER_shutdown ();
+    return;
+  }
+
   /* Get address to bind to */
   if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "rest",
                                                           "BIND_TO",
@@ -830,7 +842,6 @@ run (void *cls,
     //No address specified
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Don't know what to bind to...\n");
-    GNUNET_free (addr_str);
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
@@ -852,7 +863,6 @@ run (void *cls,
     //No address specified
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Don't know what to bind6 to...\n");
-    GNUNET_free (addr_str);
     GNUNET_SCHEDULER_shutdown ();
     return;
   }
@@ -980,11 +990,6 @@ int
 main (int argc, char *const *argv)
 {
   struct GNUNET_GETOPT_CommandLineOption options[] = {
-    GNUNET_GETOPT_option_ulong ('p',
-                                "port",
-                                "PORT",
-                                gettext_noop ("listen on specified port (default: 7776)"),
-                                &port),
     GNUNET_GETOPT_OPTION_END
   };
   static const char* err_page =
index 3674c38500976f144f2a8460721033c48b24f7f8..400db19a669dc440f161d49c9afaa2a539b153ac 100644 (file)
@@ -1,10 +1,10 @@
 [rest]
 UNIXPATH = $GNUNET_USER_RUNTIME_DIR/gnunet-service-rest.sock
 BINARY=gnunet-rest-server
-IMMEDIATE_START=YES
+START_ON_DEMAND=YES
 BIND_TO=127.0.0.1
 BIND_TO6=::1
-REST_PORT=7776
+PORT=7776
 REST_ALLOW_HEADERS=Authorization,Accept,Content-Type
 REST_ALLOW_ORIGIN=*
 REST_ALLOW_CREDENTIALS=true