diff --git a/backend/Cargo.lock b/backend/Cargo.lock index 217974e385..aa3324b349 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -34,11 +34,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" dependencies = [ "cfg-if", - "cipher", + "cipher 0.3.0", "cpufeatures", "opaque-debug", ] +[[package]] +name = "aes" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" +dependencies = [ + "cfg-if", + "cipher 0.4.4", + "cpufeatures", +] + [[package]] name = "ahash" version = "0.7.7" @@ -162,6 +173,19 @@ version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +[[package]] +name = "archiver-rs" +version = "0.5.1" +source = "git+https://github.com/gz/archiver-rs.git?branch=patch-1#a73cef92c2a5b8f48c2a4a9e889952072e03b4b7" +dependencies = [ + "bzip2", + "flate2", + "tar", + "thiserror", + "xz2", + "zip", +] + [[package]] name = "argon2" version = "0.5.2" @@ -171,7 +195,7 @@ dependencies = [ "base64ct", "blake2", "cpufeatures", - "password-hash", + "password-hash 0.5.0", ] [[package]] @@ -410,6 +434,15 @@ dependencies = [ "tokio", ] +[[package]] +name = "atoi" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c57d12312ff59c811c0643f4d80830505833c9ffaebd193d819392b265be8e" +dependencies = [ + "num-traits", +] + [[package]] name = "atoi" version = "2.0.0" @@ -539,7 +572,7 @@ dependencies = [ "async-trait", "futures-channel", "futures-util", - "parking_lot", + "parking_lot 0.12.1", "tokio", ] @@ -690,7 +723,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2cb03d1bed155d89dce0f845b7899b18a9a163e148fd004e1c28421a783e2d8e" dependencies = [ "block-padding", - "cipher", + "cipher 0.3.0", ] [[package]] @@ -1119,6 +1152,16 @@ dependencies = [ "generic-array", ] +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + [[package]] name = "clang-sys" version = "1.6.1" @@ -1258,6 +1301,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + [[package]] name = "convert_case" version = "0.4.0" @@ -1516,7 +1565,7 @@ dependencies = [ "hashbrown 0.14.2", "lock_api", "once_cell", - "parking_lot_core", + "parking_lot_core 0.9.9", ] [[package]] @@ -1635,7 +1684,7 @@ dependencies = [ "libc", "log", "once_cell", - "parking_lot", + "parking_lot 0.12.1", "pin-project", "serde", "serde_json", @@ -1705,7 +1754,7 @@ checksum = "010ce5e0a920b2364c75a9e38bcd3344bfe55a6b6cd9ef6717d78e5478f9bcb3" dependencies = [ "deno_core", "once_cell", - "rustls", + "rustls 0.21.8", "rustls-native-certs", "rustls-pemfile", "serde", @@ -1833,7 +1882,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac41dd49fb554432020d52c875fc290e110113f864c6b1b525cd62c7e7747a5d" dependencies = [ "byteorder", - "cipher", + "cipher 0.3.0", "opaque-debug", ] @@ -1858,13 +1907,22 @@ dependencies = [ "subtle", ] +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys 0.3.7", +] + [[package]] name = "dirs" version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" dependencies = [ - "dirs-sys", + "dirs-sys 0.4.1", ] [[package]] @@ -1877,6 +1935,17 @@ dependencies = [ "dirs-sys-next", ] +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "dirs-sys" version = "0.4.1" @@ -2242,6 +2311,17 @@ dependencies = [ "futures-util", ] +[[package]] +name = "futures-intrusive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a604f7a68fbf8103337523b1fadc8ade7361ee3f112f7c680ad179651616aed5" +dependencies = [ + "futures-core", + "lock_api", + "parking_lot 0.11.2", +] + [[package]] name = "futures-intrusive" version = "0.5.0" @@ -2250,7 +2330,7 @@ checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" dependencies = [ "futures-core", "lock_api", - "parking_lot", + "parking_lot 0.12.1", ] [[package]] @@ -2327,7 +2407,7 @@ dependencies = [ "hyper", "hyper-rustls", "ring 0.16.20", - "rustls", + "rustls 0.21.8", "rustls-pemfile", "serde", "serde_json", @@ -2584,7 +2664,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b780635574b3d92f036890d8373433d6f9fc7abb320ee42a5c25897fc8ed732" dependencies = [ - "dirs", + "dirs 5.0.1", "indicatif", "log", "native-tls", @@ -2716,10 +2796,10 @@ dependencies = [ "futures-util", "http", "hyper", - "rustls", + "rustls 0.21.8", "rustls-native-certs", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", ] [[package]] @@ -2820,6 +2900,15 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64e9829a50b42bb782c1df523f78d332fe371b10c661e78b7a3c34b0198e9fac" +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array", +] + [[package]] name = "instant" version = "0.1.12" @@ -3248,7 +3337,7 @@ version = "3.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0196bd5c76f5f51d7d6563545f86262fef4c82d75466ba6f6d359c40a523318d" dependencies = [ - "aes", + "aes 0.7.5", "base64 0.13.1", "block-modes", "crc-any", @@ -3277,10 +3366,10 @@ dependencies = [ "base64 0.20.0", "gethostname", "mail-builder", - "rustls", + "rustls 0.21.8", "smtp-proto", "tokio", - "tokio-rustls", + "tokio-rustls 0.24.1", "webpki-roots 0.25.2", ] @@ -3826,6 +3915,17 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core 0.8.6", +] + [[package]] name = "parking_lot" version = "0.12.1" @@ -3833,7 +3933,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core", + "parking_lot_core 0.9.9", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall 0.2.16", + "smallvec", + "winapi", ] [[package]] @@ -3858,6 +3972,17 @@ dependencies = [ "regex", ] +[[package]] +name = "password-hash" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" +dependencies = [ + "base64ct", + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "password-hash" version = "0.5.0" @@ -3881,6 +4006,18 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest 0.10.7", + "hmac", + "password-hash 0.4.2", + "sha2 0.10.8", +] + [[package]] name = "peeking_take_while" version = "0.1.2" @@ -3940,6 +4077,25 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +[[package]] +name = "pg-embed" +version = "0.7.2" +source = "git+https://github.com/faokunega/pg-embed#72db5e053f0afac6eee51d3baa2fd5c90803e02d" +dependencies = [ + "archiver-rs", + "async-trait", + "bytes", + "dirs 5.0.1", + "futures", + "lazy_static", + "log", + "reqwest", + "sqlx 0.6.3", + "thiserror", + "tokio", + "zip", +] + [[package]] name = "phf" version = "0.10.1" @@ -4427,7 +4583,7 @@ dependencies = [ "fnv", "lazy_static", "memchr", - "parking_lot", + "parking_lot 0.12.1", "thiserror", ] @@ -4511,7 +4667,7 @@ dependencies = [ "ahash 0.8.6", "equivalent", "hashbrown 0.14.2", - "parking_lot", + "parking_lot 0.12.1", ] [[package]] @@ -4817,7 +4973,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls", + "rustls 0.21.8", "rustls-pemfile", "serde", "serde_json", @@ -4825,7 +4981,7 @@ dependencies = [ "system-configuration", "tokio", "tokio-native-tls", - "tokio-rustls", + "tokio-rustls 0.24.1", "tokio-socks", "tokio-util", "tower-service", @@ -5078,6 +5234,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "rustls" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" +dependencies = [ + "log", + "ring 0.16.20", + "sct", + "webpki", +] + [[package]] name = "rustls" version = "0.21.8" @@ -5820,19 +5988,82 @@ dependencies = [ "unicode_categories", ] +[[package]] +name = "sqlx" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8de3b03a925878ed54a954f621e64bf55a3c1bd29652d0d1a17830405350188" +dependencies = [ + "sqlx-core 0.6.3", + "sqlx-macros 0.6.3", +] + [[package]] name = "sqlx" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e50c216e3624ec8e7ecd14c6a6a6370aad6ee5d8cfc3ab30b5162eeeef2ed33" dependencies = [ - "sqlx-core", - "sqlx-macros", + "sqlx-core 0.7.2", + "sqlx-macros 0.7.2", "sqlx-mysql", "sqlx-postgres", "sqlx-sqlite", ] +[[package]] +name = "sqlx-core" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa8241483a83a3f33aa5fff7e7d9def398ff9990b2752b6c6112b83c6d246029" +dependencies = [ + "ahash 0.7.7", + "atoi 1.0.0", + "base64 0.13.1", + "bitflags 1.3.2", + "byteorder", + "bytes", + "crc", + "crossbeam-queue", + "dirs 4.0.0", + "dotenvy", + "either", + "event-listener", + "futures-channel", + "futures-core", + "futures-intrusive 0.4.2", + "futures-util", + "hashlink", + "hex", + "hkdf", + "hmac", + "indexmap 1.9.3", + "itoa", + "libc", + "log", + "md-5 0.10.6", + "memchr", + "once_cell", + "paste", + "percent-encoding", + "rand 0.8.5", + "rustls 0.20.9", + "rustls-pemfile", + "serde", + "serde_json", + "sha1", + "sha2 0.10.8", + "smallvec", + "sqlformat", + "sqlx-rt", + "stringprep", + "thiserror", + "tokio-stream", + "url", + "webpki-roots 0.22.6", + "whoami", +] + [[package]] name = "sqlx-core" version = "0.7.2" @@ -5840,7 +6071,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d6753e460c998bbd4cd8c6f0ed9a64346fcca0723d6e75e52fdc351c5d2169d" dependencies = [ "ahash 0.8.6", - "atoi", + "atoi 2.0.0", "bigdecimal 0.3.1", "byteorder", "bytes", @@ -5852,7 +6083,7 @@ dependencies = [ "event-listener", "futures-channel", "futures-core", - "futures-intrusive", + "futures-intrusive 0.5.0", "futures-io", "futures-util", "hashlink", @@ -5863,7 +6094,7 @@ dependencies = [ "once_cell", "paste", "percent-encoding", - "rustls", + "rustls 0.21.8", "rustls-pemfile", "serde", "serde_json", @@ -5879,6 +6110,25 @@ dependencies = [ "webpki-roots 0.24.0", ] +[[package]] +name = "sqlx-macros" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9966e64ae989e7e575b19d7265cb79d7fc3cbbdf179835cb0d716f294c2049c9" +dependencies = [ + "dotenvy", + "either", + "heck", + "once_cell", + "proc-macro2", + "quote", + "sha2 0.10.8", + "sqlx-core 0.6.3", + "sqlx-rt", + "syn 1.0.109", + "url", +] + [[package]] name = "sqlx-macros" version = "0.7.2" @@ -5887,7 +6137,7 @@ checksum = "9a793bb3ba331ec8359c1853bd39eed32cdd7baaf22c35ccf5c92a7e8d1189ec" dependencies = [ "proc-macro2", "quote", - "sqlx-core", + "sqlx-core 0.7.2", "sqlx-macros-core", "syn 1.0.109", ] @@ -5908,7 +6158,7 @@ dependencies = [ "serde", "serde_json", "sha2 0.10.8", - "sqlx-core", + "sqlx-core 0.7.2", "sqlx-mysql", "sqlx-postgres", "sqlx-sqlite", @@ -5924,7 +6174,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "864b869fdf56263f4c95c45483191ea0af340f9f3e3e7b4d57a61c7c87a970db" dependencies = [ - "atoi", + "atoi 2.0.0", "base64 0.21.5", "bigdecimal 0.3.1", "bitflags 2.4.1", @@ -5955,7 +6205,7 @@ dependencies = [ "sha1", "sha2 0.10.8", "smallvec", - "sqlx-core", + "sqlx-core 0.7.2", "stringprep", "thiserror", "tracing", @@ -5969,7 +6219,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb7ae0e6a97fb3ba33b23ac2671a5ce6e3cabe003f451abd5a56e7951d975624" dependencies = [ - "atoi", + "atoi 2.0.0", "base64 0.21.5", "bigdecimal 0.3.1", "bitflags 2.4.1", @@ -5998,7 +6248,7 @@ dependencies = [ "sha1", "sha2 0.10.8", "smallvec", - "sqlx-core", + "sqlx-core 0.7.2", "stringprep", "thiserror", "tracing", @@ -6006,25 +6256,36 @@ dependencies = [ "whoami", ] +[[package]] +name = "sqlx-rt" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "804d3f245f894e61b1e6263c84b23ca675d96753b5abfd5cc8597d86806e8024" +dependencies = [ + "once_cell", + "tokio", + "tokio-rustls 0.23.4", +] + [[package]] name = "sqlx-sqlite" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d59dc83cf45d89c555a577694534fcd1b55c545a816c816ce51f20bbe56a4f3f" dependencies = [ - "atoi", + "atoi 2.0.0", "chrono", "flume", "futures-channel", "futures-core", "futures-executor", - "futures-intrusive", + "futures-intrusive 0.5.0", "futures-util", "libsqlite3-sys", "log", "percent-encoding", "serde", - "sqlx-core", + "sqlx-core 0.7.2", "tracing", "url", "uuid 1.5.0", @@ -6063,7 +6324,7 @@ checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b" dependencies = [ "new_debug_unreachable", "once_cell", - "parking_lot", + "parking_lot 0.12.1", "phf_shared 0.10.0", "precomputed-hash", "serde", @@ -6554,6 +6815,17 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "tar" +version = "0.4.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b16afcea1f22891c49a00c751c7b63b2233284064f11a200fc624137c51e2ddb" +dependencies = [ + "filetime", + "libc", + "xattr", +] + [[package]] name = "tempfile" version = "3.8.1" @@ -6738,7 +7010,7 @@ dependencies = [ "libc", "mio", "num_cpus", - "parking_lot", + "parking_lot 0.12.1", "pin-project-lite", "signal-hook-registry", "socket2 0.5.5", @@ -6792,7 +7064,7 @@ dependencies = [ "futures-channel", "futures-util", "log", - "parking_lot", + "parking_lot 0.12.1", "percent-encoding", "phf 0.11.2", "pin-project-lite", @@ -6805,13 +7077,24 @@ dependencies = [ "whoami", ] +[[package]] +name = "tokio-rustls" +version = "0.23.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +dependencies = [ + "rustls 0.20.9", + "tokio", + "webpki", +] + [[package]] name = "tokio-rustls" version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls", + "rustls 0.21.8", "tokio", ] @@ -6975,7 +7258,7 @@ dependencies = [ "cookie", "futures-util", "http", - "parking_lot", + "parking_lot 0.12.1", "pin-project-lite", "tower-layer", "tower-service", @@ -7390,7 +7673,7 @@ dependencies = [ "log", "native-tls", "once_cell", - "rustls", + "rustls 0.21.8", "rustls-webpki", "serde", "serde_json", @@ -7756,6 +8039,7 @@ dependencies = [ "git-version", "lazy_static", "once_cell", + "pg-embed", "prometheus", "rand 0.8.5", "reqwest", @@ -7763,7 +8047,7 @@ dependencies = [ "serde", "serde_json", "sha2 0.10.8", - "sqlx", + "sqlx 0.7.2", "tokio", "tokio-metrics", "tracing", @@ -7821,7 +8105,7 @@ dependencies = [ "serde_urlencoded", "sha2 0.10.8", "sql-builder", - "sqlx", + "sqlx 0.7.2", "tempfile", "time", "tinyvector", @@ -7869,7 +8153,7 @@ dependencies = [ "serde", "serde_json", "sql-builder", - "sqlx", + "sqlx 0.7.2", "tracing", "windmill-common", ] @@ -7895,7 +8179,7 @@ dependencies = [ "serde", "serde_json", "sha2 0.10.8", - "sqlx", + "sqlx 0.7.2", "thiserror", "tokio", "tracing", @@ -7970,7 +8254,7 @@ dependencies = [ "regex", "rustpython-parser", "serde_json", - "sqlx", + "sqlx 0.7.2", "windmill-common", "windmill-parser", ] @@ -8043,7 +8327,7 @@ dependencies = [ "serde", "serde_json", "sql-builder", - "sqlx", + "sqlx 0.7.2", "tokio", "tracing", "ulid", @@ -8092,7 +8376,7 @@ dependencies = [ "serde", "serde_json", "sha2 0.10.8", - "sqlx", + "sqlx 0.7.2", "tokio", "tokio-postgres", "tracing", @@ -8375,9 +8659,18 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" dependencies = [ + "aes 0.8.3", "byteorder", + "bzip2", + "constant_time_eq", "crc32fast", "crossbeam-utils", + "flate2", + "hmac", + "pbkdf2", + "sha1", + "time", + "zstd", ] [[package]] diff --git a/backend/Cargo.toml b/backend/Cargo.toml index c6cb4dffc0..ff6bff69c1 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -38,6 +38,7 @@ enterprise = ["windmill-worker/enterprise", "windmill-queue/enterprise", "windmi benchmark = ["windmill-api/benchmark", "windmill-worker/benchmark", "windmill-queue/benchmark"] flamegraph = ["windmill-common/flamegraph", "windmill-worker/flamegraph"] loki = ["windmill-common/loki"] +pg_embed = ["dep:pg-embed"] [dependencies] anyhow.workspace = true @@ -64,6 +65,7 @@ uuid.workspace = true gethostname.workspace = true serde_json.workspace = true serde.workspace = true +pg-embed = {git = "https://github.com/faokunega/pg-embed", optional = true} [dev-dependencies] serde_json.workspace = true diff --git a/backend/src/main.rs b/backend/src/main.rs index 70e05d2b16..a456c3208c 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -54,6 +54,9 @@ const DEFAULT_SERVER_BIND_ADDR: Ipv4Addr = Ipv4Addr::new(0, 0, 0, 0); mod ee; mod monitor; +#[cfg(feature = "pg_embed")] +mod pg_embed; + #[derive(Deserialize, PartialEq)] #[serde(rename_all = "lowercase")] pub enum Mode { @@ -166,6 +169,14 @@ async fn main() -> anyhow::Result<()> { config }); + #[cfg(feature = "pg_embed")] + let pg = { + let (db_url, pg) = pg_embed::start().await.expect("pg embed"); + tracing::info!("Use embedded pg: {db_url}"); + std::env::set_var("DATABASE_URL", db_url); + pg + }; + tracing::info!("Connecting to database..."); let db = windmill_common::connect_db(server_mode).await?; tracing::info!("Database connected"); diff --git a/backend/src/pg_embed.rs b/backend/src/pg_embed.rs new file mode 100644 index 0000000000..c4a6797d82 --- /dev/null +++ b/backend/src/pg_embed.rs @@ -0,0 +1,45 @@ +use pg_embed::pg_enums::PgAuthMethod; +use pg_embed::pg_fetch::PgFetchSettings; +use pg_embed::postgres::{PgEmbed, PgSettings}; +use std::path::PathBuf; +use std::time::Duration; + +pub async fn start() -> anyhow::Result<(String, PgEmbed)> { + let pg_settings = PgSettings { + database_dir: PathBuf::from("/tmp/db"), + port: 6543, + user: "postgres".to_string(), + password: "password".to_string(), + auth_method: PgAuthMethod::Plain, + persistent: false, + timeout: Some(Duration::from_secs(15)), + migration_dir: None, + }; + + let fetch_settings = PgFetchSettings { + version: pg_embed::pg_fetch::PostgresVersion("15.3.0"), + + ..Default::default() + }; + + tracing::info!( + "Fetch settings: {:?} {:?}", + fetch_settings.operating_system, + fetch_settings.architecture + ); + + let mut pg = PgEmbed::new(pg_settings, fetch_settings).await?; + + pg.setup().await.expect("pg setup"); + + pg.start_db().await.expect("pg start db"); + + if !pg.database_exists("windmill").await.expect("db exists") { + pg.create_database("windmill") + .await + .expect("pg create database"); + } + + let uri = pg.full_db_uri("windmill"); + Ok((uri, pg)) +} diff --git a/benchmarks/pulumi/index.ts b/benchmarks/pulumi/index.ts index b95088bfa3..2c677d6765 100644 --- a/benchmarks/pulumi/index.ts +++ b/benchmarks/pulumi/index.ts @@ -198,7 +198,7 @@ const asg = new aws.autoscaling.Group("asg3", { version: "$Latest", }, minSize: 0, - maxSize: 30, + maxSize: 2, vpcZoneIdentifiers: [subnetA.id], tags: [ { @@ -242,7 +242,7 @@ const lb = new awsx.lb.ApplicationLoadBalancer("lb2", { // desiredCount: 2, // taskDefinitionArgs: { // container: { -// image: "nginx:main@sha256:42ff38e29bae93f2122afea981d2f0344c06a099ea37a434866806c274928094", +// image: "nginx:main@sha256:31ce1955e23ec18963e5d3d7357dc68b1a62f54145d19ceff4054d257066129e", // cpu: 512, // memory: 128, // essential: true, @@ -261,7 +261,7 @@ db.address.apply((address) => { containerDefinitions: JSON.stringify([ { name: "windmill-worker", - image: "ghcr.io/windmill-labs/windmill-ee:main@sha256:42ff38e29bae93f2122afea981d2f0344c06a099ea37a434866806c274928094", + image: "ghcr.io/windmill-labs/windmill-ee:main@sha256:31ce1955e23ec18963e5d3d7357dc68b1a62f54145d19ceff4054d257066129e", cpu: 1024, memory: 1800, essential: true, @@ -273,8 +273,8 @@ db.address.apply((address) => { ], environment: [ { name: "MODE", value: "worker" }, - { name: "NUM_WORKERS", value: "1" }, - { name: "DATABASE_CONNECTIONS", value: "5"}, + { name: "NUM_WORKERS", value: "5" }, + { name: "DATABASE_CONNECTIONS", value: "10"}, { name: "SLEEP_QUEUE", value: "300"}, // { name: "METRICS_ADDR", value: "true" }, { name: "RUST_LOG", value: "info" }, @@ -319,7 +319,7 @@ db.address.apply((address) => { containerDefinitions: JSON.stringify([ { name: "windmill-worker", - image: "ghcr.io/windmill-labs/windmill-ee:main@sha256:42ff38e29bae93f2122afea981d2f0344c06a099ea37a434866806c274928094", + image: "ghcr.io/windmill-labs/windmill-ee:main@sha256:31ce1955e23ec18963e5d3d7357dc68b1a62f54145d19ceff4054d257066129e", cpu: 1024, memory: 1800, essential: true, @@ -378,7 +378,7 @@ db.address.apply((address) => { containerDefinitions: JSON.stringify([ { name: "windmill-server", - image: "ghcr.io/windmill-labs/windmill-ee:main@sha256:42ff38e29bae93f2122afea981d2f0344c06a099ea37a434866806c274928094", + image: "ghcr.io/windmill-labs/windmill-ee:main@sha256:31ce1955e23ec18963e5d3d7357dc68b1a62f54145d19ceff4054d257066129e", cpu: 1024, memory: 1024, essential: true, @@ -419,7 +419,7 @@ db.address.apply((address) => { const service_server = new aws.ecs.Service("service-server", { cluster: cluster.id, taskDefinition: server_td.arn, - desiredCount: 4, + desiredCount: 1, forceNewDeployment: true, orderedPlacementStrategies: [ { @@ -439,7 +439,7 @@ db.address.apply((address) => { const service_worker = new aws.ecs.Service("service-worker", { cluster: cluster.id, taskDefinition: worker_td.arn, - desiredCount: 20, + desiredCount: 1, forceNewDeployment: true, orderedPlacementStrategies: [ { @@ -452,7 +452,7 @@ db.address.apply((address) => { const service_worker2 = new aws.ecs.Service("service-worker-2", { cluster: cluster.id, taskDefinition: worker_td2.arn, - desiredCount: 30, + desiredCount: 0, forceNewDeployment: true, orderedPlacementStrategies: [ {