Genie Discord forum

Author Avatarsayed
7/18/2023, 6:22:58 PM

I am running my app locally and when I set GENIE_ENV="dev" it works fine but when I set GENIE_ENV="prod" it doesn't load app.jl.html showing only "build with Genie" whereas the repl shows that all the computations are done.

Author Avatarabhimanyuaryan
7/18/2023, 6:42:16 PM

maybe it's something off with socket connect can you open it again in diff browser/reload page? It should load

Author Avatarsayed
7/18/2023, 6:48:55 PM

@abhimanyuaryan For context, I am running it in the docker container. I tried it in Safari as well as Chrome. They both don't work. Here the relevant environment set up in the Dockerfile.

RUN julia --project make.jl

# ports
EXPOSE 8000
EXPOSE 80

# set up app environment
ENV JULIA_DEPOT_PATH "/home/genie/.julia"
ENV JULIA_REVISE = "off"
ENV GENIE_ENV "prod"
ENV GENIE_HOST "0.0.0.0"
ENV PORT "8000"
ENV WSPORT "8000"

ENTRYPOINT ["julia", "--project", "--sysimage=sysimg.so", "-e", "using GenieFramework; Genie.loadapp(); Genie.Generator.write_secrets_file(\".\"); up(async=false);"]```
Author Avatarsayed
7/19/2023, 5:20:25 PM

@abhimanyuaryan any insight?

Author Avatarabhimanyuaryan
7/19/2023, 10:45:02 PM

could you please share me MWE(minimum working example) that I can run a test with this docker file?

Author Avatarsayed
7/21/2023, 12:59:03 AM

Hare are all the files

# Dockerfile
# pull latest julia image
FROM --platform=linux/amd64 julia:latest

# create dedicated user
RUN useradd --create-home --shell /bin/bash genie

# set up the app
RUN mkdir /home/genie/app
COPY . /home/genie/app
WORKDIR /home/genie/app

# C compiler for PackageCompiler
RUN apt-get update && apt-get install -y g++

# configure permissions
RUN chown -R genie:genie /home/

# create genie user
USER genie

# instantiate Julia packages
RUN julia -e "using Pkg; Pkg.activate(\".\"); Pkg.instantiate(); Pkg.precompile();"

# Compile app
RUN julia --project make.jl

# ports
EXPOSE 8000
EXPOSE 80

# set up app environment
ENV JULIA_DEPOT_PATH "/home/genie/.julia"
ENV JULIA_REVISE = "off"
ENV GENIE_ENV "prod"
ENV GENIE_HOST "0.0.0.0"
ENV PORT "8000"
ENV WSPORT "8000"
# ENV EARLYBIND "true"

ENTRYPOINT ["julia", "--project", "--sysimage=sysimg.so", "-e", "using GenieFramework; Genie.loadapp(); up(async=false);"]```

Here is the `app.jl`
```julia
module App

# importing Julia packages
using GenieFramework
using DataFrames, Dates

# loading genie tools
@genietools

const private_params = Ref(params())
@private private_params

# Stipple.Observables.to_value(prp)

@app begin
    # @private const prp = Ref(params())
    @out version = "v0.1.2"
end

function ui()
    @show "ui is loaded"
    private_params[] = Genie.Router.params()                
    read("app.jl.html", String)
end
route("/") do
    # model = @init
    @page(
        "/", ui, 
        Stipple.ReactiveTools.DEFAULT_LAYOUT(title = "Stress Metrics (Vulnerability)"),
    )
end
end```
Author Avatarsayed
7/21/2023, 12:59:11 AM

Here is the app.jl.html

<h1>Analysis <q-badge :label="version"></q-badge></h1>
<div class="row">
    <div class="st-col col-2 st-module">
        <h2>Configuration</h2>
        <div class="row">
            <div class="col col-12">
                <h4 id="i61pk">Topology</h4>
            </div>
        </div>
    </div>
    <div class="st-col col-8 st-module">
        <h2>Analysis</h2>
        <div class="row">
            <div class="col col-12">
                <h4 id="iwh7j">Net Vulnerability Plot</h4>
                <div class="col col-4 col-sm">
                </div>
                <p style="color:tomato" v-text="plot_message">Default content</p>
            </div>
        </div>
        <div class="row">
            <div class="col col-12">
                <h4 id="iok84">Vulnerability Table</h4>
                <p>The impacts column represents the impact </p>
                <p style="color:tomato" v-text="table_message">Default content</p>
            </div>
        </div>
    </div>
</div>```
Author Avatarsayed
7/21/2023, 1:00:10 AM

Here is make.jl

# make.jl
using PackageCompiler

include("packages.jl")

PackageCompiler.create_sysimage(
  PACKAGES,
  sysimage_path = "sysimg.so",
  cpu_target = PackageCompiler.default_app_cpu_target()
)```
Author Avatarsayed
7/21/2023, 1:00:43 AM

Here is packages.jl

# packages.jl
const PACKAGES = [
  "GenieFramework",
  "DataFrames",
  "Dates",
  "Genie",
  "Inflector",
  "Logging",
  "Pkg",
  "TimeZones",
  "WeakRefStrings",
  "HTTP",
]```
Author Avatarabhimanyuaryan
7/25/2023, 6:26:59 AM

I don't know why would you do that?

function ui()
    @show "ui is loaded"
    private_params[] = Genie.Router.params()                
    read("app.jl.html", String)
end

route("/") do
    # model = @init
    @page(
        "/", ui, 
        Stipple.ReactiveTools.DEFAULT_LAYOUT(title = "Stress Metrics (Vulnerability)"),
    )
end

You should just use @page macro

Author Avatarabhimanyuaryan
7/25/2023, 6:28:25 AM

Why are you using params() what's the use?

Author Avatarabhimanyuaryan
7/25/2023, 6:36:30 AM

if you want private fields. Use @private macro

Author Avatarabhimanyuaryan
7/25/2023, 6:37:45 AM

just trying to understand your approach. What's your goal because this is not recommended approach also where did you find this i.e. wrapping @page in route?

Author Avatarsayed
7/26/2023, 3:46:20 AM

I am using params because I want to have the option to access the page with url params that will have the fields filled

Author Avatarsayed
7/26/2023, 3:46:29 AM

What would be the best way to do it?

Author Avatarsayed
8/1/2023, 5:39:10 PM

@abhimanyuaryan any insight on what approach to use for accessing GET query params? I am also interested in url sync with updated react fields, if you can point me to an example or help would be greatly appreciated.

Author Avatarabhimanyuaryan
8/5/2023, 1:15:22 PM

no I haven't had change sorry. Very busy lately. Tomorrow I'll look into it. Sorry for delay

Author Avatarsayed
8/22/2023, 5:15:49 PM

@abhimanyuaryan Any insgiht on this?

Author Avatarabhimanyuaryan
8/23/2023, 3:57:41 AM

@Pere can you please check this. I am busy for at least another 20 days