Terminate local payload process?

default discord avatar
itsjxcklast year
13

I'm using a local payload instance in a one-off script to fetch some data. This script is called by an external handler, so using

process.exit(0)

is not an option. Is there any way to terminate the payload instance? Otherwise this script just waits indefinitely

  • default discord avatar
    thisisnotchrislast year

    You could use a process manager like PM2 that handles starting / stopping



    Not sure if it is an option but that's a common pattern

  • default discord avatar
    itsjxcklast year

    By local payload instance I mean payload in local mode, as in just initialise the package to be able to find/update things in the db without having to start the full server and make api requests

  • default discord avatar
    thisisnotchrislast year

    How are you calling the script with an external handler



    you should be able to also send commands to the machine too right?

  • default discord avatar
    itsjxcklast year

    It's during a Redwood data migration



    So the script just exports a function which Redwood runs to migrate data in our database (separate to the Payload database)

  • default discord avatar
    thisisnotchrislast year

    im confused about "terminating the payload instance"



    you mean the express server?

  • default discord avatar
    itsjxcklast year

    No the payload package, even in local mode without Express, seems to just run forever



    It's similar to this

    https://github.com/payloadcms/nextjs-custom-server/blob/master/seed/index.js


    They solve it by using

    process.exit(0)


    Even though it has no express server it still lives on like it does

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.