Skip to content

Commit

Permalink
Auto-instantiate client apps, expose settings with logfile
Browse files Browse the repository at this point in the history
  • Loading branch information
essenciary committed Jan 23, 2024
1 parent 16c0d28 commit 3a29742
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GenieBuilder"
uuid = "c9453c14-af8a-11ec-351d-c7c9a2035d70"
authors = ["Adrian Salceanu"]
version = "0.16.46"
version = "0.16.47"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand All @@ -24,7 +24,7 @@ ZipFile = "a5390f91-8eb1-5f08-bee0-b1d1ffed6cea"

[compat]
Dates = "1.6"
Genie = "5.23.8"
Genie = "5.24.0"
GenieAutoReload = "2.2.2"
GenieDevTools = "2.9.1"
GeniePackageManager = "1.1.0"
Expand Down
24 changes: 24 additions & 0 deletions app/resources/applications/ApplicationsController.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ using Dates
using Scratch
using ZipFile
using TOML
using Logging

import StippleUI
import GeniePackageManager
Expand Down Expand Up @@ -470,6 +471,8 @@ function start(app::Application)
Pkg._auto_gc_enabled[] = false;
Pkg.activate(".");
isfile("Manifest.toml") || Pkg.instantiate();
using GenieFramework;
using GenieFramework.Revise;
Expand Down Expand Up @@ -972,6 +975,27 @@ function status()
end


"""
settings()
Returns the settings of the GenieBuilder server
"""
function settings()
logger_description = string(Logging.global_logger())
m = match(r"IOStream\(<file (.*)>\)", logger_description)
log_file = ""
if m !== nothing
log_file = m.captures[1]
end

Dict(
:settings => Dict(
:logfile => log_file,
)
) |> json
end


function download(app::Application)
app_path = fullpath(app)
endswith(app_path, "/") && (app_path = app_path[1:end-1])
Expand Down
8 changes: 7 additions & 1 deletion config/initializers/logging.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import Genie

Genie.Logger.initialize_logging()
log_path, log_name = if haskey(ENV, "GB_LOG_FILE") && ispath(dirname(ENV["GB_LOG_FILE"]))
(dirname(ENV["GB_LOG_FILE"]), basename(ENV["GB_LOG_FILE"]))
else
Genie.config.path_log, Genie.Logger.default_log_name()
end

Genie.Logger.initialize_logging(; log_path, log_name)
5 changes: 5 additions & 0 deletions routes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ function register_routes()
ApplicationsController.status()
end

# returns the settings of the GenieBuilder server
route("$gb_route/settings") do
ApplicationsController.settings()
end

nothing
end

Expand Down

0 comments on commit 3a29742

Please sign in to comment.