Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
252f9eda
Commit
252f9eda
authored
Jun 14, 2002
by
Brian Lloyd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for refactored signal handler support.
parent
368f47ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
72 deletions
+7
-72
z2.py
z2.py
+7
-72
No files found.
z2.py
View file @
252f9eda
...
...
@@ -254,74 +254,6 @@ here=os.path.join(os.getcwd(), os.path.split(program)[0])
Zpid
=
''
# Install signal handlers.
# SIGTERM - cleanly shuts down.
# SIGHUP - cleanly restarts.
# SIGUSR2 - open and close all log files (for log rotation)
if
os
.
name
==
'posix'
:
# signal.signal() not reliable on Windows
import
signal
def
closeall
():
zLOG
.
LOG
(
'Z2'
,
zLOG
.
INFO
,
"Closing all open network connections"
)
for
socket
in
asyncore
.
socket_map
.
values
():
try
:
socket
.
close
()
except
:
pass
zLOG
.
LOG
(
'Z2'
,
zLOG
.
INFO
,
"Closing all open ZODB databases"
)
import
Globals
for
db
in
Globals
.
opened
:
try
:
db
.
close
()
finally
:
pass
def
sighandler
(
signum
,
frame
):
signame
=
zdaemon
.
Daemon
.
get_signal_name
(
signum
)
zLOG
.
LOG
(
'Z2'
,
zLOG
.
INFO
,
"Caught signal %s"
%
signame
)
if
signum
in
[
signal
.
SIGTERM
,
signal
.
SIGINT
]:
closeall
()
zLOG
.
LOG
(
'Z2'
,
zLOG
.
INFO
,
"Shutting down"
)
sys
.
exit
(
0
)
if
signum
==
signal
.
SIGHUP
:
closeall
()
zLOG
.
LOG
(
'Z2'
,
zLOG
.
INFO
,
"Restarting"
)
sys
.
exit
(
1
)
if
signum
==
signal
.
SIGUSR2
:
zLOG
.
LOG
(
'Z2'
,
zLOG
.
INFO
,
"Reopening log files"
)
if
hasattr
(
sys
,
'__lg'
)
and
hasattr
(
sys
.
__lg
,
'reopen'
):
sys
.
__lg
.
reopen
()
zLOG
.
LOG
(
'Z2'
,
zLOG
.
BLATHER
,
"Reopened access log"
)
if
(
hasattr
(
sys
,
'__detailedlog'
)
and
hasattr
(
sys
.
__detailedlog
,
'reopen'
)):
zLOG
.
LOG
(
'Z2'
,
zLOG
.
BLATHER
,
"Reopened detailed request log"
)
sys
.
__detailedlog
.
reopen
()
if
hasattr
(
zLOG
,
'_set_stupid_dest'
):
zLOG
.
_set_stupid_dest
(
None
)
else
:
zLOG
.
_stupid_dest
=
None
ZLogger
.
stupidFileLogger
.
_stupid_dest
=
None
zLOG
.
LOG
(
'Z2'
,
zLOG
.
BLATHER
,
"Reopened event log"
)
zLOG
.
LOG
(
'Z2'
,
zLOG
.
INFO
,
"Log files reopened successfully"
)
INTERESTING_SIGNALS
=
{
signal
.
SIGTERM
:
sighandler
,
signal
.
SIGHUP
:
sighandler
,
signal
.
SIGUSR2
:
sighandler
,
signal
.
SIGINT
:
sighandler
,
}
def
installsighandlers
():
# normal kill, restart, and open&close logs respectively
for
signum
,
sighandler
in
INTERESTING_SIGNALS
.
items
():
signal
.
signal
(
signum
,
sighandler
)
signame
=
zdaemon
.
Daemon
.
get_signal_name
(
signum
)
zLOG
.
LOG
(
'Z2'
,
zLOG
.
BLATHER
,
"Installed sighandler for %s"
%
signame
)
########################################################################
# Configuration section
...
...
@@ -568,6 +500,9 @@ if LOCALE_ID is not None:
set_locale
(
LOCALE_ID
)
# Import SignalHandler to install the default signal handlers.
from
SignalHandler
import
SignalHandler
# from this point forward we can use the zope logger
# Import ZServer before we open the database or get at interesting
...
...
@@ -581,7 +516,7 @@ if Zpid and not READ_ONLY:
sys
.
ZMANAGED
=
1
zdaemon
.
run
(
sys
.
argv
,
os
.
path
.
join
(
CLIENT_HOME
,
Zpid
),
INTERESTING_SIGNALS
.
key
s
())
SignalHandler
.
getRegisteredSignal
s
())
os
.
chdir
(
CLIENT_HOME
)
...
...
@@ -867,7 +802,7 @@ try:
except
:
raise
# Check umask sanity
and install signal handlers
if we're on posix.
# Check umask sanity if we're on posix.
if
os
.
name
==
'posix'
:
# umask is silly, blame POSIX. We have to set it to get its value.
current_umask
=
os
.
umask
(
0
)
...
...
@@ -877,8 +812,8 @@ try:
zLOG
.
LOG
(
"z2"
,
zLOG
.
INFO
,
'Your umask of '
+
current_umask
+
\
' may be too permissive; for the security of your '
+
\
'Zope data, it is recommended you use 077'
)
# we've deferred til now to actuall install signal handlers
installsighandlers
()
except
:
# Log startup exception and tell zdaemon not to restart us.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment