how to append this plugin when using pm2
See original GitHub issueHow to append plugins is explained in two places:
- postgraphile docs: https://www.graphile.org/postgraphile/extending/
- readme of this repo: https://github.com/graphile-contrib/postgraphile-plugin-connection-filter#getting-started
Both do not explain how this would work if you are using something like pm2 to start the server which I guess almost everyone does in production.
I have tried a few solutions:
- using ecosystem.config.js:
module.exports = {
apps: [{
name: 'postgraphile',
script: './node_modules/.bin/postgraphile',
args: '-c postgres://user:password@localhost:5432/dbname --jwt-token-identifier auth.jwt_token --default-role postgres --jwt-secret secret -s dbname --cors --host 0.0.0.0 --append-plugins `pwd`/node_modules/postgraphile-plugin-connection-filter/index.js --disable-query-log',
instances: 1,
exec_mode: 'cluster',
}],
}
then starting using it:
pm2 start ecosystem.config.js
- passing options inline:
pm2 start ./node_modules/.bin/postgraphile -- -c postgres://user:password@localhost:5432/dbname --append-plugins `pwd`/node_modules/postgraphile-plugin-connection-filter/index.js --jwt-token-identifier auth.jwt_token --default-role postgres --jwt-secret secret -s dbname --cors --disable-query-log
Both lead to this error:
1|postgrap | Failed to load plugin './node_modules/postgraphile-plugin-connection-filter/index.js'
1|postgrap | Error: Cannot find module './node_modules/postgraphile-plugin-connection-filter/index.js'
1|postgrap | at Function.Module._resolveFilename (module.js:547:15)
1|postgrap | at Function.Module._load (module.js:474:25)
1|postgrap | at Module.require (module.js:596:17)
1|postgrap | at require (internal/module.js:11:18)
1|postgrap | at names.map.rawName (/home/alex/node_modules/postgraphile/build/postgraphile/cli.js:198:20)
1|postgrap | at Array.map (<anonymous>)
1|postgrap | at loadPlugins (/home/alex/node_modules/postgraphile/build/postgraphile/cli.js:190:18)
1|postgrap | at Object.<anonymous> (/home/alex/node_modules/postgraphile/build/postgraphile/cli.js:262:20)
1|postgrap | at Module._compile (module.js:652:30)
1|postgrap | at Object.Module._extensions..js (module.js:663:10)
But it works if I use:
npx postgraphile \
-c postgres://user:password@localhost:5432/dbname \
--append-plugins `pwd`/node_modules/postgraphile-plugin-connection-filter/index.js \
--jwt-token-identifier auth.jwt_token \
--default-role anon \
--jwt-secret secret \
-s dbname \
--cors
So obviously ./node_modules/postgraphile-plugin-connection-filter/index.js
exists.
The ecosystem.config approach works for me in a different project where I do not use this plugin.
So what could be wrong?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Quick Start - PM2
Start an app. The simplest way to start, daemonize and monitor your application is by using this command line: $ pm2 start app ......
Read more >Launching multiple instances of PostGraphile with PM2
A typical way to launch the PostGraphile with PM2 is as below: pm2 start --name "postgraphile" postgraphile -- --append-plugins ...
Read more >pm2 - Fig.io
Name, Description. start, Starts and daemonizes an app. trigger, Deploy your json. deploy, Deploy your json. startOrRestart, Start or restart JSON file.
Read more >node.js - How to pass execution arguments to app using PM2?
11 Answers 11 · pm2 start app.js -- dev --port=1234 (note there is an extra space between -- and dev) · pm2 start...
Read more >PM2 — Log Handling - Future Studio
PM2 has a module system that allow to extend the default with custom functionality. And there's a plugin for logrotate integration to PM2:...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ah; okay 👍 I’ve updated the docs anyway: http://graphile.org/postgraphile/extending/#loading-additional-plugins
I presume this has been resolved. If this is still an issue, please re-open.