Skip to content

Commit 8464059

Browse files
committed
documentation update
1 parent 28de453 commit 8464059

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

doc/SETTINGS.md

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -138,27 +138,32 @@ Each PEB interactive Perl script must have its own event loop waiting constantly
138138

139139
Please note that interactive Perl scripts are not supported by the Windows builds of PEB.
140140

141-
PEB interactive scripts should have ``$|=1;`` among their first lines to disable the built-in buffering of the Perl interpreter, which prevents any output before the script has ended.
141+
PEB interactive Perl script should also have the following features:
142142

143-
When PEB is closing, it sends the ``SIGTERM`` signal to all interactive scripts to prevent them from becoming zombie processes. All interactive scripts must exit in 3 seconds after the ``SIGTERM`` signal is given by PEB. All unresponsive scripts are killed before PEB exits. The ``SIGTERM`` signal may be handled by any interactive script for a graceful shutdown using the following code:
143+
* **No buffering**
144+
PEB interactive scripts should have ``$|=1;`` among their first lines to disable the built-in buffering of the Perl interpreter, which prevents any output before the script has ended.
144145

145-
```perl
146-
$SIG{TERM} = sub {
147-
# your shutdown code goes here...
148-
exit();
149-
};
150-
```
146+
* **SIGTERM handling**
147+
PEB sends the ``SIGTERM`` signal to all interactive scripts on exit for a graceful shutdown and to prevent them from becoming zombie processes. All interactive scripts must exit in 3 seconds after the ``SIGTERM`` signal is given by PEB. All unresponsive scripts are killed before PEB exits. The ``SIGTERM`` signal may be handled by any interactive script for a graceful shutdown using the following code:
151148

152-
If a PEB instance crashes, it can still leave its interactive scripts as zombie processes consuming large amounts of memory. To prevent this scenario, all interactive scripts should test for a successful ``print`` on the STDOUT. This could be implemented using the following code:
149+
```perl
150+
$SIG{TERM} = sub {
151+
# your shutdown code goes here...
152+
exit();
153+
};
154+
```
153155

154-
```perl
155-
print "output string" or shutdown_procedure();
156+
* **Failsafe print**
157+
If a PEB instance crashes, it can still leave its interactive scripts as zombie processes consuming large amounts of memory. To prevent this scenario, all interactive scripts should test for a successful ``print`` on the STDOUT. This could be implemented using the following code:
156158

157-
sub shutdown_procedure {
158-
# your shutdown code goes here...
159-
exit();
160-
}
161-
```
159+
```perl
160+
print "output string" or shutdown_procedure();
161+
162+
sub shutdown_procedure {
163+
# your shutdown code goes here...
164+
exit();
165+
}
166+
```
162167

163168
The following code shows how to start an interactive Perl script right after a local page is loaded:
164169

0 commit comments

Comments
 (0)