Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Migrate to running gluon-lang.org in a lambda #31

Merged
merged 28 commits into from
Apr 5, 2024
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Better error on openssl error
Marwes committed Apr 5, 2024
commit 27414907440ebea0d06798758586a8d72a51af35
17 changes: 10 additions & 7 deletions src/app/server.glu
Original file line number Diff line number Diff line change
@@ -155,14 +155,14 @@ let share_handler opts : Opts -> _ =
.. http.response
}

let pretty_error action msg : IO a -> String -> IO a =
do result = monad_io.catch (map Ok action) (wrap << Err)
match result with
| Ok x -> wrap x
| Err err -> error (msg <> ": " <> show err)

let load_config =
do lock_file_result
= monad_io.catch (map Ok (monad_io.read_file_to_string "Cargo.lock")) (wrap << Err)
let lock_file_contents =
match lock_file_result with
| Ok x -> x
| Err err -> error ("Unable to open `Cargo.lock`: " <> show err)
do lock_file_contents = pretty_error (monad_io.read_file_to_string "Cargo.lock") "Unable to open `Cargo.lock`"
let get_version_by_regex re_str : String -> String =
let match_ =
regex.new re_str |> result.unwrap_ok |> (\re -> regex.captures re lock_file_contents)
@@ -218,7 +218,9 @@ let setup_cert opts : Opts -> IO () =
do status = process.execute (process.proc "certbot" args)
seq when (status /= Some 0) (\_ -> error "Unable to retrieve the certificate")

do status = process.execute (process.proc "openssl"
do status =
pretty_error (
process.execute (process.proc "openssl"
["pkcs12",
"-out",
tls_cert,
@@ -229,6 +231,7 @@ let setup_cert opts : Opts -> IO () =
"-export",
"-passout",
"pass:"])
) "Unable to run `openssl`"
seq when (status /= Some 0) (\_ -> error ("Unable to convert the certificate: " ++ show status))
wrap ()