# Bukdu, How to use a Timer

**URL:** <https://discourse.julialang.org/t/bukdu-how-to-use-a-timer/54531>\
**Category:** General Usage\
**Tags:** question, package\
**Created:** [February 3, 2021, 1:35pm UTC](https://discourse.julialang.org/t/bukdu-how-to-use-a-timer/54531 "2021-02-03T13:35:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhangliye](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zhangliye/32/3208_2.png) [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Post date:** [February 3, 2021, 1:35pm UTC](https://discourse.julialang.org/t/bukdu-how-to-use-a-timer/54531/1 "2021-02-03T13:35:08Z")

</div>

When run `>julia server.jl` The `Timer` is not triggered. Is this caused by Bukdu? Thanks!

```julia
#server.jl
using Bukdu
using HTTP

const g_temp_data = Ref{String}
function do_work(t)
    g_temp_data[] ="Hello the word"
    println("call do_work()")
end
timer = Timer(do_work, 1; interval=20)

struct RouteController <: ApplicationController
    conn::Conn
end

function index(c::RouteController)
    output = g_temp_data[]
    render(JSON, output)
end
routes() do
    get("/", RouteController, index)
end

Bukdu.start(8885, host="0.0.0.0", enable_remote_ip=true)
Base.JLOptions().isinteractive == 0 && wait()

```

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [February 3, 2021, 3:50pm UTC](https://discourse.julialang.org/t/bukdu-how-to-use-a-timer/54531/2 "2021-02-03T15:50:06Z")

</div>

It looks like you never use (`wait` for) the timer, you are just creating it.

---

<div class="post-metadata">

**Author:** ![wookyoung](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wookyoung/32/157_2.png) [@wookyoung](https://discourse.julialang.org/u/wookyoung)\
**Post date:** [February 3, 2021, 4:17pm UTC](https://discourse.julialang.org/t/bukdu-how-to-use-a-timer/54531/3 "2021-02-03T16:17:02Z")

</div>

you should make `Ref{String}()`

```julia
julia> g_temp_data = Ref{String}
Ref{String}

julia> g_temp_data[] ="Hello the word"
ERROR: MethodError: no method matching setindex!(::Type{Ref{String}}, ::String)
Stacktrace:
 [1] top-level scope
   @ REPL[2]:1

julia> g_temp_data = Ref{String}()
Base.RefValue{String}(#undef)

julia> g_temp_data[] ="Hello the word"
"Hello the word"

```

and you have a question that related with Bukdu.jl, please open an issue at [https://github.com/wookay/Bukdu.jl/issues](https://github.com/wookay/Bukdu.jl/issues)

---

<div class="post-metadata">

**Author:** ![zhangliye](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zhangliye/32/3208_2.png) [@zhangliye](https://discourse.julialang.org/u/zhangliye)\
**Post date:** [February 3, 2021, 6:25pm UTC](https://discourse.julialang.org/t/bukdu-how-to-use-a-timer/54531/4 "2021-02-03T18:25:28Z")

</div>

Thank you so much! It works by adding `wait(timer)`
