Skip to content

Commit

Permalink
fix subprocess remaining
Browse files Browse the repository at this point in the history
  • Loading branch information
submarcos committed Nov 23, 2023
1 parent 7be71bd commit 445f674
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Depends:
${misc:Depends},
${shlibs:Depends},
gettext,
dumb-init,
python3 (>= 3.6),
libappindicator3-1,
libasound2,
Expand Down
8 changes: 5 additions & 3 deletions src/screenshotter/puppeteer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ def take_screenshot(url, width=1920, height=1080, waitfor='body', wait_selectors

# We send sentry informations and version : when we use screamshotter as a package, informations are in settings only
with NamedTemporaryFile(suffix='.png') as screenshot_file:
command = subprocess.Popen([
command = subprocess.run([
"/usr/local/bin/dumb-init",
"--dumb-init",
"--",
os.getenv('NODE_BIN_PATH', 'node'),
app_settings.PUPPETEER_JAVASCRIPT_FILEPATH,
'--version',
Expand Down Expand Up @@ -52,10 +55,9 @@ def take_screenshot(url, width=1920, height=1080, waitfor='body', wait_selectors
screamshotter_css_class,
'--headers',
json.dumps(forward_headers),
], stderr=subprocess.PIPE, env=os.environ, preexec_fn=os.setsid)
], stderr=subprocess.PIPE, env=os.environ)

if command.stderr:
raise ScreenshotterException(command.stderr.decode())

os.killpg(os.getpgid(command.pid), signal.SIGTERM)
return screenshot_file.read()

0 comments on commit 445f674

Please sign in to comment.