Run on any port
This commit is contained in:
parent
ac18e3741f
commit
e57e758834
17
README.md
17
README.md
@ -65,14 +65,23 @@ To set up a development environment:
|
||||
|
||||
4. Build and run the application from source:
|
||||
```bash
|
||||
# Run with a persistent database
|
||||
# Run with a persistent database on default port (8000)
|
||||
cargo run -- -d rss-reader.db
|
||||
|
||||
# Or try it out in demo mode (uses in-memory database)
|
||||
cargo run -- --demo
|
||||
# Run on a specific port
|
||||
cargo run -- -d rss-reader.db -p 3000
|
||||
|
||||
# Run in demo mode with custom port
|
||||
cargo run -- --demo -p 8080
|
||||
```
|
||||
|
||||
The application will be available at `http://localhost:8000`.
|
||||
The application will be available at `http://localhost:<port>` (default port is 8000).
|
||||
|
||||
### Command Line Options
|
||||
|
||||
- `-d, --database <PATH>` - Path to the SQLite database file (required unless in demo mode)
|
||||
- `--demo` - Run in demo mode with an in-memory database
|
||||
- `-p, --port <PORT>` - Port to listen on (default: 8000)
|
||||
|
||||
### Running in Production
|
||||
|
||||
|
4
justfile
4
justfile
@ -4,8 +4,8 @@ _default:
|
||||
export SECRET_KEY := "MHSePvm1msyOkYuJ7u+MtyJYCzgdHCS7QNvrk9ts+rI="
|
||||
|
||||
[doc("Run the reader locally in demo mode.")] # don't re-use this secret key
|
||||
run-local-demo:
|
||||
cargo run -- --demo
|
||||
run-local-demo *args:
|
||||
cargo run -- --demo {{args}}
|
||||
|
||||
sqlx-prepare:
|
||||
DATABASE_URL="sqlite:data.sqlite" cargo sqlx prepare
|
||||
|
@ -28,6 +28,10 @@ struct Args {
|
||||
/// Run in demo mode with an in-memory database
|
||||
#[arg(long)]
|
||||
demo: bool,
|
||||
|
||||
/// Port to listen on
|
||||
#[arg(short, long, default_value_t = 8000)]
|
||||
port: u16,
|
||||
}
|
||||
|
||||
#[derive(Database)]
|
||||
@ -101,6 +105,7 @@ fn rocket() -> _ {
|
||||
|
||||
let figment = rocket::Config::figment()
|
||||
.merge(("databases.rss_data.url", db_url))
|
||||
.merge(("port", args.port))
|
||||
.merge((
|
||||
"secret_key",
|
||||
std::env::var("SECRET_KEY").expect("SECRET_KEY environment variable must be set"),
|
||||
|
Loading…
Reference in New Issue
Block a user