Skip to content

Commit

Permalink
Merge branch 'nightly' into release/nightly/bin/ncproxy/0.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
leon3s authored Jun 6, 2024
2 parents 8e86fce + 9c952fb commit 59d71a7
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 53 deletions.
78 changes: 39 additions & 39 deletions bin/nanocld/src/tasks/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,51 +153,51 @@ impl ObjTaskUpdate for CargoDb {
cargo.spec.cargo_key
);
let state_ptr_ptr = state.clone();
rt::spawn(async move {
ntex::time::sleep(std::time::Duration::from_secs(2)).await;
let _ = utils::container::delete_instances(
&new_instances
.iter()
.map(|p| p.key.clone())
.collect::<Vec<_>>(),
&state_ptr_ptr,
)
.await;
let res = processes
let _ = utils::container::delete_instances(
&new_instances
.iter()
.map(|process| {
let docker_api = state_ptr_ptr.inner.docker_api.clone();
async move {
docker_api
.rename_container(
&process.key,
RenameContainerOptions {
name: &process.name,
},
)
.await?;
Ok::<_, HttpError>(())
}
})
.collect::<FuturesUnordered<_>>()
.collect::<Vec<_>>()
.await
.into_iter()
.collect::<HttpResult<Vec<_>>>();
if let Err(err) = res {
log::error!("Unable to rename containers back: {err}");
}
});
.map(|p| p.key.clone())
.collect::<Vec<_>>(),
&state_ptr_ptr,
)
.await;
let res = processes
.iter()
.map(|process| {
let docker_api = state_ptr_ptr.inner.docker_api.clone();
async move {
docker_api
.rename_container(
&process.key,
RenameContainerOptions {
name: &process.name,
},
)
.await?;
Ok::<_, HttpError>(())
}
})
.collect::<FuturesUnordered<_>>()
.collect::<Vec<_>>()
.await
.into_iter()
.collect::<HttpResult<Vec<_>>>();
if let Err(err) = res {
log::error!("Unable to rename containers back: {err}");
}
}
Ok(_) => {
log::debug!("cargo instance {} started", cargo.spec.cargo_key);
// Delete old containers
let state_ptr_ptr = state.clone();
let _ = utils::container::delete_instances(
&processes.iter().map(|p| p.key.clone()).collect::<Vec<_>>(),
&state_ptr_ptr,
)
.await;
rt::spawn(async move {
ntex::time::sleep(std::time::Duration::from_secs(4)).await;
let _ = utils::container::delete_instances(
&processes.iter().map(|p| p.key.clone()).collect::<Vec<_>>(),
&state_ptr_ptr,
)
.await;
});
}
}
ObjPsStatusDb::update_actual_status(
Expand Down
6 changes: 6 additions & 0 deletions bin/ncproxy/src/models/templates/http.conf
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ server {
proxy_ssl_certificate_key {{location.ssl.CertificateKey}};
{% endif %}
}{% endfor %}{% endif %}
proxy_connect_timeout 2s;
proxy_send_timeout 2s;
proxy_read_timeout 2s;
proxy_next_upstream error timeout;
proxy_next_upstream_timeout 2s;
proxy_next_upstream_tries 3;
}
25 changes: 12 additions & 13 deletions bin/ncproxy/src/models/templates/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
user root;
worker_processes auto;

pid /run/nginx.pid;

include /etc/nginx/modules-enabled/*.conf;

worker_processes auto;

worker_rlimit_nofile 15360;

worker_shutdown_timeout 240s;

events {
worker_connections 4096;
#multi_accept on;
multi_accept on;
worker_connections 16384;
use epoll;
}

##
Expand Down Expand Up @@ -100,21 +106,14 @@ http {
## Enable gzip compression
gzip on;
gzip_vary on;
# gzip_proxied any;
gzip_comp_level 9;
gzip_proxied any;
gzip_comp_level 4;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types image/webp image/png text/plain text/css text/xml text/javascript application/x-javascript application/javascript application/xml font/eot font/otf font/ttf;
gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml image/x-icon image/vnd.microsoft.icon application/vnd.ms-fontobject application/x-font-ttf application/font-woff application/font-woff2 font/opentype;
## Disable gzip for IE6
gzip_disable "MSIE [1-6].";

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

##
# Virtual Host Configs
##
Expand Down
2 changes: 1 addition & 1 deletion bin/ncproxy/src/utils/nginx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub async fn ensure_conf(state: &SystemStateRef) -> IoResult<()> {
"log",
"secrets",
]
.into_iter()
.iter()
.map(|name| {
fs::create_dir_all(format!("{}/{}", state_ref.store.dir, name))?;
Ok::<_, IoError>(())
Expand Down
4 changes: 4 additions & 0 deletions bin/ncproxy/src/utils/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ pub async fn get_addresses(
) -> IoResult<Vec<String>> {
let mut addresses = vec![];
for process in processes {
log::debug!("get_addresses from: {}", process.name);
if process.name.starts_with("tmp-") {
continue;
}
let networks = process
.data
.network_settings
Expand Down

0 comments on commit 59d71a7

Please sign in to comment.