socketry / falcon-rails-example

25 stars 1 forks source link

How to change default port for development #3

Open JProgrammer opened 10 months ago

JProgrammer commented 10 months ago

I'm looking to run multiple local api serves on rails falcon, to do so I need to set different default ports for the applications.

The only part of the code that references the default port 3000 is in the puma.rb which I assume is from the generated rails code that does not seem to run when using Falcon.

ioquatix commented 5 months ago

falcon serve can take a bind argument:

falcon [--verbose | --quiet] [-h/--help] [-v/--version] [-e/--encoding] <command>
    An asynchronous HTTP server.

    [--verbose | --quiet]  Verbosity of output for debugging.                        
    [-h/--help]            Print out help information.                               
    [-v/--version]         Print out the application version.                        
    [-e/--encoding]        Specify the default external encoding of the server.        (default: UTF-8)
    <command>              One of: serve, host, virtual, proxy, redirect, supervisor.  (default: serve)

    serve [-b/--bind <address>] [-p/--port <number>] [-h/--hostname <hostname>] [-t/--timeout <duration>] [-c/--config <path>] [--preload <path>] [--cache] [--forked | --threaded | --hybrid] [-n/--count <count>] [--forks <count>] [--threads <count>] [--[no]-restart] [--graceful-stop <timeout>]
        Run an HTTP server for development purposes.

        [-b/--bind <address>]               Bind to the given hostname/address.                              (default: https://localhost:9292)
        [-p/--port <number>]                Override the specified port.                                   
        [-h/--hostname <hostname>]          Specify the hostname which would be used for certificates, etc.
        [-t/--timeout <duration>]           Specify the maximum time to wait for non-blocking operations.  
        [-c/--config <path>]                Rackup configuration file to load.                               (default: config.ru)             
        [--preload <path>]                  Preload the specified path before creating containers.         
        [--cache]                           Enable the response cache.                                     
        [--forked | --threaded | --hybrid]  Select a specific parallelism model.                             (default: forked)                
        [-n/--count <count>]                Number of instances to start.                                    (default: 10)                    
        [--forks <count>]                   Number of forks (hybrid only).                                 
        [--threads <count>]                 Number of threads (hybrid only).                               
        [--[no]-restart]                    Enable/disable automatic restart.                                (default: true)                  
        [--graceful-stop <timeout>]         Duration to wait for graceful stop.                              (default: 1.0)                   

For example: falcon serve --bind http://localhost:1234

In addition, you can use falcon host, with a falcon.rb file, which can also specify the port number, e.g. https://github.com/socketry/falcon/blob/93b113cb0f7e1a17791037efc4ed45c7f1915bf8/lib/falcon/environment/server.rb#L41