summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2019-12-17 13:01:41 -0500
committerEugeniy E. Mikhailov <evgmik@gmail.com>2019-12-17 13:01:41 -0500
commit3c4207c4aa55644c35600d7bdc2fcbba2b757824 (patch)
tree1f3e14d952bdb8c7bd51c7b2cfee46520bbcd820 /init.lua
downloadnodeMCU_rf_source_lmx2487-3c4207c4aa55644c35600d7bdc2fcbba2b757824.tar.gz
nodeMCU_rf_source_lmx2487-3c4207c4aa55644c35600d7bdc2fcbba2b757824.zip
init
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua39
1 files changed, 39 insertions, 0 deletions
diff --git a/init.lua b/init.lua
new file mode 100644
index 0000000..9f1ca8b
--- /dev/null
+++ b/init.lua
@@ -0,0 +1,39 @@
+dofile("local_config.lua")
+dofile("config.lua")
+
+-- Compile server code and remove original .lua files.
+-- This only happens the first time afer the .lua files are uploaded.
+local compileAndRemoveIfNeeded = function(f)
+ if file.open(f) then
+ file.close()
+ print('Compiling:', f)
+ node.compile(f)
+ file.remove(f)
+ collectgarbage()
+ end
+end
+
+local serverFiles = {
+ 'httpserver.lua',
+ 'httpserver-b64decode.lua',
+ 'httpserver-basicauth.lua',
+ 'httpserver-conf.lua',
+ 'httpserver-connection.lua',
+ 'httpserver-error.lua',
+ 'httpserver-header.lua',
+ 'httpserver-request.lua',
+ 'httpserver-static.lua',
+ 'telnetserver.lua'
+}
+for i, f in ipairs(serverFiles) do compileAndRemoveIfNeeded(f) end
+
+compileAndRemoveIfNeeded = nil
+serverFiles = nil
+collectgarbage()
+
+
+-- some diagnostic
+print('chip: ',node.chipid())
+print('heap: ',node.heap())
+
+dofile("main.lua")