Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cloudooo
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
cloudooo
Commits
cedd433c
Commit
cedd433c
authored
5 years ago
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve logging
parent
a5157949
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
18 deletions
+50
-18
cloudooo/handler/ooo/application/application.py
cloudooo/handler/ooo/application/application.py
+29
-11
cloudooo/handler/ooo/application/openoffice.py
cloudooo/handler/ooo/application/openoffice.py
+6
-5
cloudooo/handler/ooo/handler.py
cloudooo/handler/ooo/handler.py
+11
-1
cloudooo/handler/ooo/mimemapper.py
cloudooo/handler/ooo/mimemapper.py
+4
-1
No files found.
cloudooo/handler/ooo/application/application.py
View file @
cedd433c
...
...
@@ -29,8 +29,7 @@
from
zope.interface
import
implements
from
cloudooo.interfaces.application
import
IApplication
from
cloudooo.util
import
logger
from
cloudooo.handler.ooo.util
import
waitStopDaemon
from
psutil
import
pid_exists
,
Process
,
AccessDenied
from
psutil
import
pid_exists
,
Process
,
AccessDenied
,
TimeoutExpired
,
NoSuchProcess
class
Application
(
object
):
...
...
@@ -47,17 +46,36 @@ class Application(object):
self
.
getAddress
()[
-
1
],
self
.
pid
()))
def
stop
(
self
):
def
stop
Process
(
self
,
process_pid
):
"""Stop the process"""
if
hasattr
(
self
,
'process'
)
and
self
.
status
():
process_pid
=
self
.
process
.
pid
logger
.
debug
(
"Stop Pid - %s"
%
process_pid
)
error
=
False
logger
.
debug
(
"Stop Pid - %s"
,
process_pid
)
returncode
=
None
try
:
process
=
Process
(
process_pid
)
cmdline
=
" "
.
join
(
process
.
cmdline
())
process
.
terminate
()
returncode
=
process
.
wait
(
self
.
timeout
)
except
NoSuchProcess
:
pass
except
TimeoutExpired
:
error
=
True
logger
.
error
(
"Process %s survived SIGTERM after %s"
,
process_pid
,
self
.
timeout
)
try
:
self
.
process
.
terminate
()
waitStopDaemon
(
self
,
self
.
timeout
)
finally
:
if
pid_exists
(
process_pid
)
or
self
.
status
():
Process
(
process_pid
).
kill
()
process
.
kill
()
returncode
=
process
.
wait
(
self
.
timeout
)
except
NoSuchProcess
:
pass
except
TimeoutExpired
:
logger
.
error
(
"Process %s survived SIGKILL after %s"
,
process_pid
,
self
.
timeout
)
if
error
and
returncode
:
logger
.
error
(
"Process %s cmdline: %s ended with returncode %s"
,
process_pid
,
cmdline
,
returncode
)
elif
returncode
!=
0
:
logger
.
debug
(
"Process %s ended with returncode %s"
,
process_pid
,
returncode
)
def
stop
(
self
):
if
hasattr
(
self
,
'process'
):
self
.
stopProcess
(
self
.
process
.
pid
)
delattr
(
self
,
"process"
)
def
loadSettings
(
self
,
hostname
,
port
,
path_run_dir
,
**
kwargs
):
...
...
This diff is collapsed.
Click to expand it.
cloudooo/handler/ooo/application/openoffice.py
View file @
cedd433c
...
...
@@ -37,7 +37,7 @@ from application import Application
from
cloudooo.interfaces.lockable
import
ILockable
from
cloudooo.util
import
logger
,
convertStringToBool
from
cloudooo.handler.ooo.util
import
waitStartDaemon
,
\
removeDirectory
,
waitStopDaemon
,
\
removeDirectory
,
\
socketStatus
...
...
@@ -105,7 +105,6 @@ class OpenOffice(Application):
"""Start OpenOffice.org process"""
for
i
in
range
(
5
):
self
.
stop
()
waitStopDaemon
(
self
,
self
.
timeout
)
self
.
process
=
Popen
(
command
,
close_fds
=
True
,
env
=
env
)
...
...
@@ -121,14 +120,16 @@ class OpenOffice(Application):
for
connection
in
process
.
connections
():
if
connection
.
status
==
"LISTEN"
and
\
connection
.
laddr
[
1
]
==
self
.
port
:
process
.
terminate
()
self
.
stopProcess
(
process
.
pid
)
break
except
AccessDenied
,
e
:
pass
except
TypeError
,
e
:
# exception to prevent one psutil issue with zombie processes
logger
.
debug
(
e
)
logger
.
error
(
e
)
except
NotImplementedError
,
e
:
logger
.
error
(
"lsof isn't installed on this machine: "
+
str
(
e
))
logger
.
error
(
"lsof isn't installed on this machine: %s"
,
str
(
e
))
break
def
start
(
self
,
init
=
True
):
"""Start Instance."""
...
...
This diff is collapsed.
Click to expand it.
cloudooo/handler/ooo/handler.py
View file @
cedd433c
...
...
@@ -119,11 +119,18 @@ class Handler(object):
self
.
_startTimeout
()
process
=
Popen
(
command_list
,
stdout
=
PIPE
,
stderr
=
PIPE
,
close_fds
=
True
,
env
=
openoffice
.
environment_dict
.
copy
())
logger
.
debug
(
"Process %s running"
,
process
.
pid
)
stdout
,
stderr
=
process
.
communicate
()
finally
:
self
.
_stopTimeout
()
if
pid_exists
(
process
.
pid
):
logger
.
debug
(
"Process %s terminated"
,
process
.
pid
)
process
.
terminate
()
if
(
process
.
returncode
<
0
and
process
.
returncode
!=
-
6
)
or
stderr
:
logger
.
error
(
"Process %s command:%s"
,
process
.
pid
,
" "
.
join
(
command_list
))
logger
.
error
(
"Process %s stdout:%s"
,
process
.
pid
,
stdout
)
logger
.
error
(
"Process %s stderr:%s"
,
process
.
pid
,
stderr
)
logger
.
debug
(
"Process %s terminated with returncode %s"
,
process
.
pid
,
process
.
returncode
)
return
stdout
,
stderr
def
_callUnoConverter
(
self
,
*
feature_list
,
**
kw
):
...
...
@@ -131,7 +138,9 @@ class Handler(object):
if
not
openoffice
.
status
():
openoffice
.
start
()
command_list
=
self
.
_getCommand
(
*
feature_list
,
**
kw
)
logger
.
debug
(
"run convert first"
)
stdout
,
stderr
=
self
.
_subprocess
(
command_list
)
logger
.
debug
(
"stop convert first"
)
if
not
stdout
and
stderr
:
first_error
=
stderr
logger
.
error
(
stderr
)
...
...
@@ -139,10 +148,11 @@ class Handler(object):
openoffice
.
restart
()
kw
[
'document_url'
]
=
self
.
document
.
getUrl
()
command
=
self
.
_getCommand
(
*
feature_list
,
**
kw
)
logger
.
debug
(
"run convert second"
)
stdout
,
stderr
=
self
.
_subprocess
(
command
)
logger
.
debug
(
"stop convert second"
)
if
not
stdout
and
stderr
:
second_error
=
"
\
n
error of the second run: "
+
stderr
logger
.
error
(
second_error
)
raise
Exception
(
first_error
+
second_error
)
return
stdout
,
stderr
...
...
This diff is collapsed.
Click to expand it.
cloudooo/handler/ooo/mimemapper.py
View file @
cedd433c
...
...
@@ -33,6 +33,7 @@ from subprocess import STDOUT
from
zope.interface
import
implements
from
filter
import
Filter
from
os
import
environ
,
path
from
cloudooo.util
import
logger
from
cloudooo.interfaces.mimemapper
import
IMimemapper
from
types
import
InstanceType
import
json
...
...
@@ -124,8 +125,10 @@ class MimeMapper(object):
"--hostname=%s"
%
hostname
,
"--port=%s"
%
port
]
process
=
Popen
(
command
,
stdout
=
PIPE
,
stderr
=
STDOUT
,
close_fds
=
True
)
process
=
Popen
(
command
,
stdout
=
PIPE
,
stderr
=
PIPE
,
close_fds
=
True
)
stdout
,
stderr
=
process
.
communicate
()
if
stderr
:
logger
.
error
(
stderr
)
if
process
.
returncode
:
raise
ValueError
(
stdout
)
filter_dict
,
type_dict
=
json
.
loads
(
stdout
)
...
...
This diff is collapsed.
Click to expand it.
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