Добавлена обработка подпроцессов.
authorRoman Bazalevsky <rvb@rvb.name>
Thu, 6 Dec 2018 06:41:54 +0000 (09:41 +0300)
committerRoman Bazalevsky <rvb@rvb.name>
Thu, 6 Dec 2018 06:41:54 +0000 (09:41 +0300)
bin/weathermon
init.d/weathermon
lib/wm_util.lua
openwrt-web/meteo/archive.js
web/config_local.php~ [deleted file]

index 2314e1a4122cf8fe02f5e1950b0d8ff6397592ad..8da469650890303c2483c028df13c797f1104b7c 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/lua
 
 local json = require("json")
+local signal = require("posix.signal")
 
 require "wm_util"
 
@@ -307,6 +308,19 @@ end
 
 getConfig(arg[1])
 
+signal.signal(signal.SIGTERM, function(signum)
+
+  printLog("Terminating...")
+  local pids = get_children()
+  for k,v in pairs(pids) do
+    printLog("Terminating subprocess "..tostring(v).."...")
+    signal.kill(v,signal.SIGTERM)
+  end
+  printLog("Exiting...")
+  os.exit(0)
+
+end)
+
 if backlogdb or logdb then
   local dbdriver = require "luasql.sqlite3"
   env = assert(dbdriver.sqlite3())
index bbf6f210bb607b32d2526622b217e8146f2698d4..8553b6ac39c7919111a4a32ac1c4f101d9cd3757 100755 (executable)
@@ -48,7 +48,5 @@ start_service() {
 }
 
 stop_service() {
-       killall weathermon
-       killall weathermon-iio
        /usr/bin/weather-backup
 }
index 984f6aeebfbc873c84e08e99c7321dd09445acab..2c05bb054cb882f6fcfb8d381d44cd442cbfdfb6 100644 (file)
@@ -1,6 +1,9 @@
 #!/usr/bin/lua
 
 local socket = require "socket"
+local lfs = require "lfs"
+local uci = require "uci"
+local posix = require "posix"
 
 function startswith(String,Start)
    if String then
@@ -95,7 +98,6 @@ function split(s, delimiter)
 end
 
 function list_dir(name)
-    local lfs = require "lfs"
     local result = {}
     for name in lfs.dir(name) do
         if not startswith(name,".") then
@@ -107,8 +109,6 @@ end
 
 function get_devid(config)
 
-  local uci = require "uci"
-
   local web_devid = uci.get(config,"web","devid")
   
   if web_devid then
@@ -126,4 +126,26 @@ function get_devid(config)
   local web_devid = io.read("*line")
   return web_devid:gsub(":",""):upper()
 
-end
\ No newline at end of file
+end
+
+function get_children()
+
+  local pid = posix.getpid()
+  local pidlist = list_dir('/proc')
+  local pids = {}
+
+  for k,v in pairs(pidlist) do
+
+    pcall( function ()
+      local stats = get_file_content('/proc/'..v..'/stat')
+      local ppid = tonumber(split(stats,' ')[4])
+      if pid == ppid then
+        pids[#pids+1] = tonumber(v)
+      end 
+    end)
+
+  end
+
+  return pids
+
+end
index 20aa7aa6bd25d735fad2cff4821110796b769796..a0850e46780c4eac639f4aeb65cb128892b086f9 100644 (file)
@@ -146,7 +146,7 @@ function drawGraph(graphData) {
           yAxes: [{
             scaleLabel: {
               display: true,
-              labelString: properties["names"][sensor+"."+param],
+              labelString: properties["names"][devid+"."+sensor+"."+param] + ", " + properties["units"][devid+"."+sensor+"."+param],
               fontColor: properties["fonts"]["axes"]["color"],
               fontSize: properties["fonts"]["axes"]["size"],
               fontStyle: properties["fonts"]["axes"]["style"],
diff --git a/web/config_local.php~ b/web/config_local.php~
deleted file mode 100644 (file)
index 1ca0c18..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-  $mysql_host = 'estia.rvb-home.lan';
-  $mysql_schema = 'meteo';
-  $mysql_user = 'meteo';
-  $mysql_pwd = 'snovadozhdi';
-  $mysql_port = 3306;
-
-  setlocale(LC_ALL,'ru_RU.UTF8');
-
-  $site_header = 'RVB.NAME';
-                
-?>