Documentation
Server

Server

The server provides the cup serve command.

Basic usage

$ cup serve
2024-07-17T09:08:38.724922Z    INFO   xitca_server::net  :  Started Tcp listening on: Some(0.0.0.0:8000)                                                                              
2024-07-17T09:08:38.725076Z    WARN   xitca_server::server::future  :  ServerFuture::wait is called from within tokio context. It would block current thread from handling async tasks
2024-07-17T09:08:38.725248Z    INFO   xitca_server::worker  :  Started xitca-server-worker-0                                                                                          
2024-07-17T09:08:38.725343Z    INFO   xitca_server::worker  :  Started xitca-server-worker-1                                                                                          
2024-07-17T09:08:38.725580Z    INFO   xitca_server::worker  :  Started xitca-server-worker-2                                                                                          
2024-07-17T09:08:38.725607Z    INFO   xitca_server::worker  :  Started xitca-server-worker-3                                                                                          
2024-07-17T09:08:41.390783Z    INFO   request  {  method  = GET  uri  = / }  :   on_request  :  serving request                       
2024-07-17T09:08:41.390905Z    INFO   request  {  method  = GET  uri  = / }  :   on_response  :  sending response

This will launch the server on port 8000. To access it, visit http://<YOUR_IP>:8000 (replace <YOUR_IP> with the IP address of the machine running Cup.)

💡

The URL http://<YOUR_IP>:8000/json is also available for usage with integrations.

Use a different port

Pass the -p argument with the port you want to use

$ cup serve -p 9000
2024-07-17T09:08:38.724922Z    INFO   xitca_server::net  :  Started Tcp listening on: Some(0.0.0.0:9000)                                                                              
2024-07-17T09:08:38.725076Z    WARN   xitca_server::server::future  :  ServerFuture::wait is called from within tokio context. It would block current thread from handling async tasks
2024-07-17T09:08:38.725248Z    INFO   xitca_server::worker  :  Started xitca-server-worker-0                                                                                          
2024-07-17T09:08:38.725343Z    INFO   xitca_server::worker  :  Started xitca-server-worker-1                                                                                          
2024-07-17T09:08:38.725580Z    INFO   xitca_server::worker  :  Started xitca-server-worker-2                                                                                          
2024-07-17T09:08:38.725607Z    INFO   xitca_server::worker  :  Started xitca-server-worker-3                                                                                          
2024-07-17T09:08:41.390783Z    INFO   request  {  method  = GET  uri  = / }  :   on_request  :  serving request                       
2024-07-17T09:08:41.390905Z    INFO   request  {  method  = GET  uri  = / }  :   on_response  :  sending response

Usage with Docker

If you're using the Docker image, just replace all occurences of cup in the examples with docker run -tv /var/run/docker.sock:/var/run/docker.sock -p <PORT>:<PORT> ghcr.io/sergi0g/cup, where <PORT> is the port Cup will be using.

For example, this:

$ cup serve -p 9000

becomes:

$ docker run -tv /var/run/docker.sock:/var/run/docker.sock -p 9000:9000 ghcr.io/sergi0g/cup serve -p 9000