Skip to content

Commit

Permalink
Auto-open started app, fix open app on close, auto-register, auto-start
Browse files Browse the repository at this point in the history
  • Loading branch information
essenciary committed Nov 15, 2023
1 parent e7f562b commit 2e86e73
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion 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.12"
version = "0.16.13"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
26 changes: 15 additions & 11 deletions app/resources/applications/ApplicationsController.jl
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,19 @@ function create(app::Application; name::AbstractString = "", path::AbstractStrin

(:status => OKSTATUS) |> json
end
function create(app::Nothing; name::AbstractString = "", path::AbstractString = pwd(), autostart::Bool = true, autoregister::Bool = true)
isdir(path) || mkpath(path)

create_output = create(GenieBuilder.app!(name, path))
function create(app::Nothing; name::AbstractString = "", path::AbstractString = pwd())
try
isdir(path) || mkpath(path)
register(name, path; autostart = false)

register_output = ""
autoregister && (register_output = register(name, path; autostart))
app = GenieBuilder.app!(name, path)
create(app)
start(app)

isempty(register_output) ? create_output : register_output
return (:status => OKSTATUS) |> json
catch ex
return (:status => FAILSTATUS, :error => ex) |> json
end
end
create(name::AbstractString = "", path::AbstractString = pwd()) = create(findone(Application; name = isempty(name) ? name_from_path(path) : name))

Expand Down Expand Up @@ -417,7 +421,10 @@ function start(app::Application)
using GenieFramework.Genie;
Core.eval(Main, :(const UserApp = $(@__MODULE__)));
Genie.genie(context = @__MODULE__);
up(; async = false, open_browser = true);
up(; async = true, open_browser = true);
while true
sleep(1)
end
'`; dir = fullpath(app), detach = false)
cmd = addenv(cmd, "PORT" => app.port,
"WSPORT" => app.port,
Expand All @@ -433,9 +440,6 @@ function start(app::Application)

app.error = ""
save!(app)

sleep(3)
GenieBuilder.openbrowser(app)
catch ex
@error ex
notify("failed:start", app.id, FAILSTATUS, ERROR_STATUS)
Expand Down
8 changes: 4 additions & 4 deletions routes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ status(app::Union{Application,Nothing}) = ApplicationsController.status(app)

# starts the app
function start(app::Application)
@async begin
sleep(15)
openbrowser(app)
end
# @async begin
# sleep(15)
# openbrowser(app)
# end
ApplicationsController.start(app)
end

Expand Down

0 comments on commit 2e86e73

Please sign in to comment.