fix port issue

This commit is contained in:
Bevan Hunt 2020-02-04 15:49:57 -08:00
parent 5848b62c39
commit 0a658e43f1
5 changed files with 11 additions and 9 deletions

2
Cargo.lock generated
View File

@ -113,7 +113,7 @@ dependencies = [
[[package]]
name = "broker"
version = "4.2.8"
version = "4.2.9"
dependencies = [
"Inflector 0.11.4 (registry+https://github.com/rust-lang/crates.io-index)",
"bcrypt 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -1,6 +1,6 @@
[package]
name = "broker"
version = "4.2.8"
version = "4.2.9"
authors = ["Bevan Hunt <bevan@bevanhunt.com>"]
edition = "2018"
license = "MIT"

View File

@ -172,7 +172,7 @@ pub async fn main() {
- the expiry (for jwts) needs to be passed in as a flag
- the secret (for jwts) needs to be passed in as a flag
- the save_path where the embedded database will save needs to be passed in as an environment variable
- example: SAVE_PATH=./tmp/broker_data broker -port 8080 -origin http://localhost:3000 -expiry 3600 -secret secret
- example: SAVE_PATH=./tmp/broker_data broker --port 8080 --origin http://localhost:3000 --expiry 3600 --secret secret
### Install Crate
@ -182,7 +182,7 @@ pub async fn main() {
- the expiry (for jwts) needs to be passed in as a flag
- the secret (for jwts) needs to be passed in as a flag
- the save_path where the embedded database will save needs to be passed in as an environment variable
- example: SAVE_PATH=./tmp/broker_data broker -port 8080 -origin http://localhost:3000 -expiry 3600 -secret secret
- example: SAVE_PATH=./tmp/broker_data broker --port 8080 --origin http://localhost:3000 --expiry 3600 --secret secret
### Install Linux Snap
@ -193,7 +193,7 @@ pub async fn main() {
- the port needs to be passed in as a flag
- the expiry (for jwts) needs to be passed in as a flag
- the secret (for jwts) needs to be passed in as a flag
- example: sudo broker -port 8080 -origin http://localhost:3000 -expiry 3600 -secret secret
- example: sudo broker -port 8080 --origin http://localhost:3000 --expiry 3600 --secret secret
### Under the Hood

View File

@ -1,6 +1,6 @@
name: broker # you probably want to 'snapcraft register <name>'
base: core18 # the base snap is the execution environment for this snap
version: '4.2.8' # just for humans, typically '1.2+git' or '1.3.2'
version: '4.2.9' # just for humans, typically '1.2+git' or '1.3.2'
summary: Real-time BaaS (Backend as a Service) # 79 char long summary
description: |
The purpose of this library is to be your real-time BaaS (Backend as a Service).

View File

@ -16,6 +16,7 @@ use crossbeam::channel::unbounded;
use inflector::Inflector;
use json_patch::merge;
use std::sync::{Arc, Mutex};
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
// init database as lazy
lazy_static! {
@ -59,7 +60,7 @@ pub struct SSE {
#[derive(Deserialize, Debug, Clone)]
pub struct Config {
pub port: String,
pub port: u16,
pub expiry: i64,
pub origin: String,
pub secret: String,
@ -413,7 +414,7 @@ fn login(tree: sled::Db, login: Login, config: Config) -> (bool, String) {
// config based on sane local dev defaults (uses double dashes for flags)
fn config() -> Config {
let mut port = "8080".to_owned();
let mut port : u16 = 8080;
let mut expiry : i64 = 3600;
let mut origin = "http://localhost:3000".to_owned();
let mut secret = "secret".to_owned();
@ -717,5 +718,6 @@ pub async fn broker() {
let routes = warp::any().and(login_route).or(user_create_route).or(insert_route).or(sse_route).or(cancel_route).or(collections_route).or(user_collection_route).with(cors);
// start server
warp::serve(routes).run(([0, 0, 0, 0], 8080)).await
let socket = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), configure.port);
warp::serve(routes).run(socket).await
}