R
RunPod•5w ago
AC

JS pupeteer issue

Hi, I have a pupeteer chromium task that i want to run on the runpod which is written in typescript. I did not see any JS handler. So, i am calling the JS entrypoint via python as below.
""" Example handler file. """

import runpod
from subprocess import call
import os

# If your handler runs inference on a model, load the model here.
# You will want models to be loaded into memory before starting serverless.


def handler(job):
""" Handler function that will be used to process jobs. """
job_input = job['input']

prompt_id = job_input.get('aiPromptId')
video_save_path = job_input.get('videoSavePath')

# Create a copy of the current environment variables
env = os.environ.copy()

# Add or update the required environment variables
env['AI_PROMPT_ID'] = prompt_id
env['VIDEO_SAVE_PATH'] = video_save_path
print("env", env)

print("Running the executeDockerCommand")
# env['NODE_ENV'] = 'development'

call(["yarn", "ts-node", "src/backend/executeDockerCommand.ts"], env=env)

print("Finish running the command")

return f"Hello, {prompt_id}!"


runpod.serverless.start({"handler": handler})
""" Example handler file. """

import runpod
from subprocess import call
import os

# If your handler runs inference on a model, load the model here.
# You will want models to be loaded into memory before starting serverless.


def handler(job):
""" Handler function that will be used to process jobs. """
job_input = job['input']

prompt_id = job_input.get('aiPromptId')
video_save_path = job_input.get('videoSavePath')

# Create a copy of the current environment variables
env = os.environ.copy()

# Add or update the required environment variables
env['AI_PROMPT_ID'] = prompt_id
env['VIDEO_SAVE_PATH'] = video_save_path
print("env", env)

print("Running the executeDockerCommand")
# env['NODE_ENV'] = 'development'

call(["yarn", "ts-node", "src/backend/executeDockerCommand.ts"], env=env)

print("Finish running the command")

return f"Hello, {prompt_id}!"


runpod.serverless.start({"handler": handler})
The above code works fine locally. But, when i deploy to serverless, it kicks off the yarn ts-node ... , but gets stuck and does not emit any logs and eventually times out. Any advice?
25 Replies
nerdylive
nerdylive•5w ago
Use codes block it's better to write code inside a code block This is how you write block code: ``` import subprocess import runpod ``` It will be like:
import subprocess
import runpod
import subprocess
import runpod
It does emit logs, if it does in your local when you call it manually in your command line But the logs from your process(cli you call using subprocess didn't go through runpod's log) So what you have to do is:
from runpod import RunPodLogger
# change this to your command ( also put this inside a handler code )
x = subprocess.run(["cmd", "/c", "dir"], capture_output=True)
# initialize the logger object
logger = RunPodLogger()
# log the output from your process
logger.info(f'{x.stdout.decode()}')
from runpod import RunPodLogger
# change this to your command ( also put this inside a handler code )
x = subprocess.run(["cmd", "/c", "dir"], capture_output=True)
# initialize the logger object
logger = RunPodLogger()
# log the output from your process
logger.info(f'{x.stdout.decode()}')
AC
AC•5w ago
Awesome! Let me try that in the morning.
AC
AC•5w ago
Looks like still stuck and does not emit log or proceeds
No description
nerdylive
nerdylive•5w ago
It does It says it couldn't read that folder
AC
AC•5w ago
i take that back. Its pupetteer launch issue. I am launching pupeteer with these options
const puppeteerLaunchOpts: PuppeteerLaunchOptions = {
// headless: shouldPerformanceTrace() ? false : 'shell',
headless: true,
devtools: isDev,
args: ['--disable-gpu', '--no-sandbox', '--disable-setuid-sandbox'],
};

const browser = await puppeteer.launch(puppeteerLaunchOpts)
const puppeteerLaunchOpts: PuppeteerLaunchOptions = {
// headless: shouldPerformanceTrace() ? false : 'shell',
headless: true,
devtools: isDev,
args: ['--disable-gpu', '--no-sandbox', '--disable-setuid-sandbox'],
};

const browser = await puppeteer.launch(puppeteerLaunchOpts)
Looks like this gets stuck
nerdylive
nerdylive•5w ago
I c
AC
AC•5w ago
It works fine locally 🤔 i am ssh'ing into the serverless and still seeing the same issue
nerdylive
nerdylive•5w ago
whats the error? can you copy in text? maybe i can help
AC
AC•5w ago
its just stuck
nerdylive
nerdylive•5w ago
stuck in what? any logs?
AC
AC•5w ago
There are no logs being emitted by puppeteer.launch I added logs before and after puppeteer.launch and the log after launch doesnt get triggered.
AC
AC•5w ago
No description
nerdylive
nerdylive•5w ago
is that warn normal or what
AC
AC•5w ago
yea. thats normal it emits locally as well. Unrelated Has anyone ran pupeteer successfully?
nerdylive
nerdylive•5w ago
hmm i dont know about that send me the full file maybe let me see
AC
AC•5w ago
sure. Let me isolate keys and just keep the pupeteer code
AC
AC•5w ago
This is the entire file
AC
AC•5w ago
The entry point is generateAndUploadVideoViaPuppeteer
nerdylive
nerdylive•5w ago
try dumpio = true on launchBrowser put it in args
AC
AC•5w ago
got it! trying
nerdylive
nerdylive•5w ago
whats the logs after
AC
AC•5w ago
No description
AC
AC•5w ago
Got this now Is there something i need to turn on gpu support via dockerfile?
nerdylive
nerdylive•5w ago
no i dont think so search the problem up i think its like dependency problem only
AC
AC•5w ago
Got it. Let me search around.
Want results from more Discord servers?
Add your server
More Posts