# Triggering hot reloading externally

**URL:** <https://forum.defold.com/t/triggering-hot-reloading-externally/3200>\
**Category:** Questions\
**Created:** [October 16, 2016, 11:01am UTC](https://forum.defold.com/t/triggering-hot-reloading-externally/3200 "2016-10-16T11:01:50Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![dapetcu21](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/dapetcu21/32/25120_2.png) [@dapetcu21](https://forum.defold.com/u/dapetcu21)\
**Post date:** [October 16, 2016, 11:01am UTC](https://forum.defold.com/t/triggering-hot-reloading-externally/3200/1 "2016-10-16T11:01:50Z")

</div>

So, I’m working on [Atom Defold IDE](https://forum.defold.com/t/lua-autocomplete-for-atom/3170). Been using it a bit and I’ve been finding myself pressing Cmd-R and Cmd-B while in Atom quite a lot. Is there/will there be a way to trigger hot reloading and/or rebuilding programmatically in the current editor or in Editor2?

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [October 17, 2016, 4:56am UTC](https://forum.defold.com/t/triggering-hot-reloading-externally/3200/2 "2016-10-17T04:56:06Z")

</div>

You can build and run from the command line using bob and dmengine, but that’s about it. I’m not aware of any way of interfacing with the editor to trigger a build or hot reload of content. @Erik_Angelin and @Ragnar_Svensson, would that be possible using the new editor?

---

<div class="post-metadata">

**Author:** ![Ragnar\_Svensson](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/r/b5ac83/32.png) [@Ragnar\_Svensson](https://forum.defold.com/u/Ragnar_Svensson)\
**Post date:** [October 17, 2016, 9:59am UTC](https://forum.defold.com/t/triggering-hot-reloading-externally/3200/3 "2016-10-17T09:59:59Z")

</div>

The only way to build (which is also needed for hot-reload) programmatically is through bob. For the hot-reload, the Editor simply tells the engine to reload via HTTP, so this could be done from somewhere else. We have no plans to be able to control Editor1/Editor2 programmatically yet, sorry. It would be quite some time before we would look into that.

---

<div class="post-metadata">

**Author:** ![dapetcu21](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/dapetcu21/32/25120_2.png) [@dapetcu21](https://forum.defold.com/u/dapetcu21)\
**Post date:** [October 17, 2016, 1:49pm UTC](https://forum.defold.com/t/triggering-hot-reloading-externally/3200/4 "2016-10-17T13:49:22Z")

</div>

That’s cool. I took a look with Wireshark and noticed that you do a POST to `localhost:8001/post/@resource/reload` with `\n<path_len><path_to_compiled_file>`. I managed to trigger a hot reload with curl this way, but I had to run `bob` to compile the file beforehand. I’m not sure though if `bob` does a full compilation or is incremental, as it seemed to be just slightly slower than from within the editor. I’ll implement this in Defold IDE, thanks.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [October 17, 2016, 7:22pm UTC](https://forum.defold.com/t/triggering-hot-reloading-externally/3200/5 "2016-10-17T19:22:52Z")

</div>

> [@dapetcu21](#):
>
> I’m not sure though if bob does a full compilation or is incremental

bob is incremental, unless you do a clean first.

---

<div class="post-metadata">

**Author:** ![Ragnar\_Svensson](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/r/b5ac83/32.png) [@Ragnar\_Svensson](https://forum.defold.com/u/Ragnar_Svensson)\
**Post date:** [October 17, 2016, 9:00pm UTC](https://forum.defold.com/t/triggering-hot-reloading-externally/3200/6 "2016-10-17T21:00:14Z")

</div>

It’s also slower, partly because it needs to start the JVM every time.

---

<div class="post-metadata">

**Author:** ![dapetcu21](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/dapetcu21/32/25120_2.png) [@dapetcu21](https://forum.defold.com/u/dapetcu21)\
**Post date:** [October 17, 2016, 9:13pm UTC](https://forum.defold.com/t/triggering-hot-reloading-externally/3200/7 "2016-10-17T21:13:40Z")

</div>

I tried running it with Drip. Didn’t help by much. I suspect it’s all the `stat()`-ing it needs to do before it figures out which files need recompilation and which don’t. I’m not aiming for a perfect replacement anyway.

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [October 1, 2018, 10:30am UTC](https://forum.defold.com/t/triggering-hot-reloading-externally/3200/8 "2018-10-01T10:30:13Z")

</div>

@dapetcu21 Is this something like this?

```lua
curl -d "\n\022/main/main.scriptc" -X POST localhost:49757/post/@resource/reload

```

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [October 1, 2018, 12:33pm UTC](https://forum.defold.com/t/triggering-hot-reloading-externally/3200/9 "2018-10-01T12:33:18Z")

</div>

Hmm. this doesn’t work.  
Can you manage to trigger Hot reloading @dapetcu21 ? But I cound’t find a way to trigger with curl. Am I missing something?

Defold post looks like this.  
 ![30](https://defold-forum-bucket.nbg1.your-objectstorage.com/original/2X/8/8adef0b6af6fadb088e723a5381ec937d2b2ccc7.png)

---

<div class="post-metadata">

**Author:** ![dapetcu21](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/dapetcu21/32/25120_2.png) [@dapetcu21](https://forum.defold.com/u/dapetcu21)\
**Post date:** [October 1, 2018, 1:43pm UTC](https://forum.defold.com/t/triggering-hot-reloading-externally/3200/10 "2018-10-01T13:43:38Z")

</div>

They probably changed the way it gets triggered.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [October 1, 2018, 2:57pm UTC](https://forum.defold.com/t/triggering-hot-reloading-externally/3200/11 "2018-10-01T14:57:06Z")

</div>

> [@dapetcu21](#):
>
> They probably changed the way it gets triggered.

Maybe, not sure. @Johan_Beck-Noren do you know?

---

<div class="post-metadata">

**Author:** ![Johan\_Beck-Noren](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/johan_beck-noren/32/2622_2.png) [@Johan\_Beck-Noren](https://forum.defold.com/u/Johan_Beck-Noren)\
**Post date:** [October 1, 2018, 3:00pm UTC](https://forum.defold.com/t/triggering-hot-reloading-externally/3200/12 "2018-10-01T15:00:09Z")

</div>

Not that I know, but I think @Erik_Angelin dabbled with this last week 🙂

---

<div class="post-metadata">

**Author:** ![Erik\_Angelin](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/e/59ef9b/32.png) [@Erik\_Angelin](https://forum.defold.com/u/Erik_Angelin)\
**Post date:** [October 1, 2018, 3:17pm UTC](https://forum.defold.com/t/triggering-hot-reloading-externally/3200/13 "2018-10-01T15:17:44Z")

</div>

I’ll pass the question on to @mats.gisselson 🙂

---

<div class="post-metadata">

**Author:** ![Erik\_Angelin](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/e/59ef9b/32.png) [@Erik\_Angelin](https://forum.defold.com/u/Erik_Angelin)\
**Post date:** [October 1, 2018, 4:28pm UTC](https://forum.defold.com/t/triggering-hot-reloading-externally/3200/14 "2018-10-01T16:28:00Z")

</div>

This code has practically not changed for a couple of years. You’re supposed to send a protobuf message consisting of the resource path to reload (as a string), I suppose encoded like this: [Encoding | Protocol Buffers Documentation](https://developers.google.com/protocol-buffers/docs/encoding#strings)  
I.e. prefixed by length. Not sure about the type + field number, would have guessed there should be a leading 0x02. Note that all of this is subject to change, but, well, probably not soon 🙂

---

<div class="post-metadata">

**Author:** ![selimanac](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/selimanac/32/6397_2.png) [@selimanac](https://forum.defold.com/u/selimanac)\
**Post date:** [October 2, 2018, 7:37am UTC](https://forum.defold.com/t/triggering-hot-reloading-externally/3200/15 "2018-10-02T07:37:52Z")

</div>

Thank you @Erik_Angelin, I’l try it.
