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
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
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
How are you calling the script with an external handler
you should be able to also send commands to the machine too right?
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)
im confused about "terminating the payload instance"
you mean the express server?
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
Discord
online
Get help straight from the Payload team with an Enterprise License.