Tue, 31 Aug 2021 20:48:37 +0200
Split batch, adjust mash step volume. In the duplicated log_brew handle the missing values. In save product, round the mash step sg to 4 decimals. In prod_edit, ingredients are stored as strings, not arrays. This triggered a memory corruption that only happened in rare circumstances. Don't fix mash step fields in the javascript, it is already done during load from the database. Calculation of the mash volume is rounded to 6 decimals. Enter mash step Brix/Plato value, the SG result is rounded to 4 decimals.
574 | 1 | #! /bin/sh |
2 | ### BEGIN INIT INFO | |
3 | # Provides: bmsd | |
4 | # Required-Start: $local_fs $remote_fs $network $syslog | |
5 | # Required-Stop: $local_fs $remote_fs $network $syslog | |
6 | # Should-Start: mosquitto | |
7 | # Should-Stop: mosquitto | |
8 | # Default-Start: 2 3 4 5 | |
9 | # Default-Stop: 0 1 6 | |
10 | # Short-Description: Brewery Management Daemon | |
11 | # Description: This program is the central daemon to collect data | |
12 | # from and control remote devices in a brewery. It is | |
13 | # the production and inventory database. | |
14 | ### END INIT INFO | |
15 | ||
16 | # Author: Michiel Broek <mbroek@mbse.eu> | |
17 | ||
18 | # Do NOT "set -e" | |
19 | ||
20 | # PATH should only include /usr/* if it runs after the mountnfs.sh script | |
21 | PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
22 | DESC="Brewery Management Daemon" | |
23 | NAME=bmsd | |
24 | DAEMON=/var/lib/bms/bin/$NAME | |
25 | #DAEMON_ARGS="--options args" | |
26 | PIDFILE=/var/lib/bms/.bms/run/$NAME.pid | |
27 | SCRIPTNAME=/etc/init.d/$NAME | |
28 | ||
29 | # Exit if the package is not installed | |
30 | [ -x "$DAEMON" ] || exit 0 | |
31 | ||
32 | # Read configuration variable file if it is present | |
33 | [ -r /etc/default/$NAME ] && . /etc/default/$NAME | |
34 | ||
35 | # Load the VERBOSE setting and other rcS variables | |
36 | . /lib/init/vars.sh | |
37 | ||
38 | # Define LSB log_* functions. | |
39 | # Depend on lsb-base (>= 3.2-14) to ensure that this file is present | |
40 | # and status_of_proc is working. | |
41 | . /lib/lsb/init-functions | |
42 | ||
43 | # | |
44 | # Function that starts the daemon/service | |
45 | # | |
46 | do_start() | |
47 | { | |
575
fd9e4838648f
Improved init script for Debian systems
Michiel Broek <mbroek@mbse.eu>
parents:
574
diff
changeset
|
48 | # Return |
fd9e4838648f
Improved init script for Debian systems
Michiel Broek <mbroek@mbse.eu>
parents:
574
diff
changeset
|
49 | # 0 if daemon has been started |
fd9e4838648f
Improved init script for Debian systems
Michiel Broek <mbroek@mbse.eu>
parents:
574
diff
changeset
|
50 | # 1 if daemon was already running |
fd9e4838648f
Improved init script for Debian systems
Michiel Broek <mbroek@mbse.eu>
parents:
574
diff
changeset
|
51 | # other if daemon could not be started or a failure occured |
fd9e4838648f
Improved init script for Debian systems
Michiel Broek <mbroek@mbse.eu>
parents:
574
diff
changeset
|
52 | start-stop-daemon --start --chuid brewery --exec $DAEMON |
574 | 53 | } |
54 | ||
55 | # | |
56 | # Function that stops the daemon/service | |
57 | # | |
58 | do_stop() | |
59 | { | |
575
fd9e4838648f
Improved init script for Debian systems
Michiel Broek <mbroek@mbse.eu>
parents:
574
diff
changeset
|
60 | # Return |
fd9e4838648f
Improved init script for Debian systems
Michiel Broek <mbroek@mbse.eu>
parents:
574
diff
changeset
|
61 | # 0 if daemon has been stopped |
fd9e4838648f
Improved init script for Debian systems
Michiel Broek <mbroek@mbse.eu>
parents:
574
diff
changeset
|
62 | # 1 if daemon was already stopped |
fd9e4838648f
Improved init script for Debian systems
Michiel Broek <mbroek@mbse.eu>
parents:
574
diff
changeset
|
63 | # other if daemon could not be stopped or a failure occurred |
fd9e4838648f
Improved init script for Debian systems
Michiel Broek <mbroek@mbse.eu>
parents:
574
diff
changeset
|
64 | start-stop-daemon --stop --retry=TERM/30/KILL/5 --pidfile $PIDFILE --exec $DAEMON |
574 | 65 | } |
66 | ||
67 | # | |
68 | # Function that sends a SIGHUP to the daemon/service | |
69 | # | |
70 | do_reload() { | |
71 | # | |
72 | # If the daemon can reload its configuration without | |
73 | # restarting (for example, when it is sent a SIGHUP), | |
74 | # then implement that here. | |
75 | # | |
76 | return 0 | |
77 | } | |
78 | ||
79 | case "$1" in | |
80 | start) | |
81 | [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" | |
82 | do_start | |
83 | case "$?" in | |
84 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; | |
85 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; | |
86 | esac | |
87 | ;; | |
88 | stop) | |
89 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" | |
90 | do_stop | |
91 | case "$?" in | |
92 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; | |
93 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; | |
94 | esac | |
95 | ;; | |
96 | status) | |
97 | status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? | |
98 | ;; | |
99 | #reload|force-reload) | |
100 | # | |
101 | # If do_reload() is not implemented then leave this commented out | |
102 | # and leave 'force-reload' as an alias for 'restart'. | |
103 | # | |
104 | #log_daemon_msg "Reloading $DESC" "$NAME" | |
105 | #do_reload | |
106 | #log_end_msg $? | |
107 | #;; | |
108 | restart|force-reload) | |
109 | # | |
110 | # If the "reload" option is implemented then remove the | |
111 | # 'force-reload' alias | |
112 | # | |
113 | log_daemon_msg "Restarting $DESC" "$NAME" | |
114 | do_stop | |
115 | case "$?" in | |
116 | 0|1) | |
117 | do_start | |
118 | case "$?" in | |
119 | 0) log_end_msg 0 ;; | |
120 | 1) log_end_msg 1 ;; # Old process is still running | |
121 | *) log_end_msg 1 ;; # Failed to start | |
122 | esac | |
123 | ;; | |
124 | *) | |
125 | # Failed to stop | |
126 | log_end_msg 1 | |
127 | ;; | |
128 | esac | |
129 | ;; | |
130 | *) | |
131 | echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 | |
132 | exit 3 | |
133 | ;; | |
134 | esac | |
135 | ||
136 | : |