How to start strapi server with python subprocess

Viewed 86

I try to write a script that starts strapi server automatically and print log outout with python subprocess

process = subprocess.Popen(
    ["yarn", "develop" if watch_mode else "start"],
    stdout=subprocess.PIPE)

And get the output

while True:
    output = process.stdout.readline()
    if (output == '') and (process.poll() is not None):
        break
    if output:
        print(output.strip())

But when I run it, there is an error

events.js:377
      throw er; // Unhandled 'error' event
      ^

Error: write EPIPE
    at afterWriteDispatched (internal/stream_base_commons.js:156:25)
    at writeGeneric (internal/stream_base_commons.js:147:3)
    at Socket._writeGeneric (net.js:798:11)
    at Socket._write (net.js:810:8)
    at writeOrBuffer (internal/streams/writable.js:358:12)
    at Socket.Writable.write (internal/streams/writable.js:303:10)
    at console.value (internal/console/constructor.js:289:16)
    at console.log (internal/console/constructor.js:363:26)
    at Strapi.logStats (/home/my_name/strapi_project/node_modules/strapi/lib/Strapi.js:99:13)
    at Strapi.logFirstStartupMessage (/home/my_name/strapi_project/node_modules/strapi/lib/Strapi.js:126:10)
    at onListen (/home/my_name/strapi_project/node_modules/strapi/lib/Strapi.js:253:16)
Emitted 'error' event on Socket instance at:
    at Socket.onerror (/home/my_name/strapi_project/node_modules/readable-stream/lib/_stream_readable.js:640:52)
    at Socket.emit (events.js:400:28)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  errno: -32,
  code: 'EPIPE',
  syscall: 'write'
}
error Command failed with exit code 1.
0 Answers
Related