Skip to content

Commit f366990

Browse files
Add reboot
1 parent fbe8386 commit f366990

File tree

7 files changed

+31
-5
lines changed

7 files changed

+31
-5
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ dist-any:
5555
cp -ru $(LUAJLS)/jls/ $(LHA_DIST)/lua/
5656
cp -ru lha/ $(LHA_DIST)/lua/
5757
cp -u lha.sh $(LHA_DIST)/
58-
cp -u lha.bat $(LHA_DIST)/
58+
cp -u lha.cmd $(LHA_DIST)/
5959
cp -u *.lua $(LHA_DIST)/
6060
cp -ru extensions/ $(LHA_DIST)/
6161
cp -ru assets/ $(LHA_DIST)/

extensions/hue/HueBridge.lua

+2
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ return require('jls.lang.class').create(function(hueBridge)
553553
function hueBridge:updateThing(thing, info, isEvent)
554554
for name in pairs(thing:getProperties()) do
555555
local computeFn = computeFnByName[name] or getInfoProperty
556+
---@diagnostic disable-next-line: redundant-parameter
556557
local value = computeFn(info, name, self)
557558
if isValue(value) then
558559
thing:updatePropertyValue(name, value)
@@ -563,6 +564,7 @@ return require('jls.lang.class').create(function(hueBridge)
563564
function hueBridge:setThingPropertyValue(thing, id, name, value)
564565
local category = categoryByName[name]
565566
local toPostFn = toPostFnByName[name] or toPost
567+
---@diagnostic disable-next-line: redundant-parameter
566568
local t = toPostFn(value, name)
567569
local path
568570
if thing:hasType(Thing.CAPABILITIES.OnOffSwitch) or thing:hasType(Thing.CAPABILITIES.Light) then

extensions/web-tools/web-tools.js

+5
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ define(['./web-tools.xml'], function(toolsTemplate) {
9090
fetch('/engine/admin/restart', { method: 'POST'});
9191
});
9292
},
93+
rebootServer: function() {
94+
confirmation.ask('Reboot the server?').then(function() {
95+
fetch('/engine/admin/reboot', { method: 'POST'});
96+
});
97+
},
9398
stopServer: function() {
9499
confirmation.ask('Stop the server?').then(function() {
95100
fetch('/engine/admin/stop', { method: 'POST'}).then(function() {

extensions/web-tools/web-tools.xml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<p>Engine</p>
2121
<button v-on:click="stopServer"><i class="fas fa-power-off"></i>&nbsp;Stop the Server</button>
2222
<button v-on:click="restartServer"><i class="fas fa-redo"></i>&nbsp;Restart the Server</button>
23+
<button v-on:click="rebootServer"><i class="fas fa-redo"></i>&nbsp;Reboot the Server</button>
2324
<p>Advanced</p>
2425
<button v-on:click="reloadExtensions"><i class="fas fa-redo"></i>&nbsp;Reload the Extensions</button>
2526
<button v-on:click="reloadScripts"><i class="fas fa-redo"></i>&nbsp;Reload the Scripts</button>

lha.cmd

+6-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
bin\lua lha.lua %*
1+
@echo off
2+
:bof
3+
bin\lua lha.lua %*
4+
set STATUS=%ERRORLEVEL%
5+
if %STATUS% equ 11 goto bof
6+
exit /b %STATUS%

lha.sh

100644100755
+7-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
#!/bin/sh
2-
exec bin/lua lha.lua $@
2+
status=11
3+
while test $status -eq 11
4+
do
5+
bin/lua lha.lua $@
6+
status=$?
7+
done
8+
exit $status

lha/restEngine.lua

+9-2
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ local REST_ADMIN = {
157157
exchange.attributes.engine:reloadScripts(mode == 'full')
158158
return 'Done'
159159
end,
160+
['reboot?method=POST'] = function(exchange)
161+
event:setTimeout(function()
162+
exchange.attributes.engine:stop()
163+
runtime.exit(11)
164+
end, 100)
165+
return 'In progress'
166+
end,
160167
['restart?method=POST'] = function(exchange)
161168
event:setTimeout(function()
162169
exchange.attributes.engine:stop()
@@ -165,8 +172,8 @@ local REST_ADMIN = {
165172
end, 100)
166173
return 'In progress'
167174
end,
168-
-- curl -X POST http://localhost:8080/engine/stop
169-
['stop?method=POST'] = function(exchange)
175+
-- curl -X POST http://localhost:8080/engine/stop
176+
['stop?method=POST'] = function(exchange)
170177
event:setTimeout(function()
171178
exchange.attributes.engine:stop()
172179
event:stop()

0 commit comments

Comments
 (0)