Skip to content
This repository has been archived by the owner on Jun 15, 2020. It is now read-only.

No9/rust-tide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust Tide Stack

This has now been merged into the main appsody repository

https://github.com/appsody/stacks/tree/master/experimental/rust-tide

The Rust Tide stack provides a consistent way of developing tide http servers.

Designed to be used with Appsody an open source development and operations accelerator for containers.

This stack is based on the Rust 1.42 runtime.

Templates

Templates are used to create your local project and start your development. When initializing your project you will be provided with the default template project. This template provides a http server that returns "Hello World" on http://localhost:8000/hello.

Getting Started

  1. Clone this repo and configure appsody

    git clone https://github.com/No9/rust-tide
    cd rust-tide
    appsody stack package
  2. Create a new folder in your local directory and initialize it using the Appsody CLI, e.g.:

    mkdir my-project
    cd my-project
    appsody init dev.local/rust-tide

    This will initialize a Tide project using the default template.

  3. After your project has been initialized you can then run your application using the following command:

    appsody run

    This launches a Docker container that continuously re-builds and re-runs your project. It also exposes port 8000 to allow you to call your service from your browser and test tooling.

  4. You should see a message printed on the console:

    Running `server/bin/target/debug/rust-tide-server

  5. Open a browser at http://localhost:8000/hello

    It should return Hello, world.

  6. Now open lib.rs and change world to tide and save the file.

    pub fn app() -> tide::server::Server<()> {    
        let mut api = tide::new();
        api.at("/hello").get(|_| async move { "Hello, Tide" });
        api
    }
  7. Your application will be rebuild and republished so refresh http://localhost:8000/hello it will now say Hello, Tide

Debugging

To debug your application running in a container, start the container using:

    appsody debug --docker-options "--cap-add=SYS_PTRACE --security-opt seccomp=unconfined"

The command will start the LLDB platform and wait for incoming connections from any address to port 1234.

You can connect lldb in remote debug mode to this container as follows:

lldb \
  -o "platform select remote-linux" \
  -o "platform connect connect://localhost:1234" \
  -o "platform settings -w /project/server/bin/target/debug" \
  -o "file rust-tide-server" 

Once in lldb, you can use breakpoint set to set breakpoints in your application, and then run to start the app.

NOTE: Due to a current limitation, breakpoints must be set before the application is run. Breakpoints can be disabled, but cannot be re-enabled without restarting the app. After adding or re-enabling breakpoints, restart the app with process kill and then run.

License

This stack is licensed under the Apache 2.0 license

Releases

No releases published

Packages

No packages published