Running a plugin on one node
-
Hey guys, was wondering if there was a way to have nodebb run a plugin on the main instance? For plugins like nodebb-plugin-camo, if local camo is selected, it will try to spin up a camo instance for each node in a cluster setup (cluster of size 3 -> 3 camo nodes)
-
if (nconf.get('isPrimary') === 'true') { // do stuff only on the primary node }
If you have nodebb running on multiple machines you can also add jobsDisabled: true to config.json on some of the machines and check for it in your code.
As in
if (nconf.get('isPrimary') === 'true' && !nconf.get('jobsDisabled')) { // do stuff on the primary node and only if jobs not disabled }
-
@Bri Hi. I have not thoroughly tested camo in a clustered environment yet, but currently in a 3 cluster setup, when it tries to spin up 3 nodes, 2 of them should silently fail, because they cannot all bind to the camo port.
I'll add baris's code to the next update so that it only tries to spawn once.
-
I thought so too, but when I spin up on my local (on the old version), I see 6 new node processes.
Just tried it out (with a tiny fix), looking good! I just noticed that I don't seem to get any log output from Camo
-
As far as I know, it only sends a message when it's spawned and killed. You're getting nothing at all?
-
nothing
NodeBB v1.0.3 Copyright (C) 2013-2014 NodeBB Inc. This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. For the full license, please visit: http://www.gnu.org/copyleft/gpl.html Clustering enabled: Spinning up 3 process(es). 27/4 18:10 [67457] - info: Time: Wed Apr 27 2016 18:10:06 GMT-0700 (PDT) 27/4 18:10 [67457] - info: Initializing NodeBB v1.0.3 27/4 18:10 [67459] - info: [database] Checking database indices. 27/4 18:10 [67457] - info: [database] Checking database indices. 27/4 18:10 [67458] - info: [database] Checking database indices. 27/4 18:10 [67458] - warn: [socket.io] Clustering detected, you are advised to configure Redis as a websocket store. 27/4 18:10 [67457] - warn: [socket.io] Clustering detected, you are advised to configure Redis as a websocket store. 27/4 18:10 [67459] - warn: [socket.io] Clustering detected, you are advised to configure Redis as a websocket store. 27/4 18:10 [67457] - warn: [plugins/load] The following plugins may not be compatible with your version of NodeBB. This may cause unintended behaviour or crashing. In the event of an unresponsive NodeBB caused by this plugin, run `./nodebb reset -p PLUGINNAME` to disable it. * nodebb-plugin-import * nodebb-plugin-spoilers 27/4 18:10 [67457] - info: NodeBB Ready 27/4 18:10 [67457] - info: Enabling 'trust proxy' 27/4 18:10 [67457] - info: NodeBB is now listening on: 0.0.0.0:4567 27/4 18:10 [67458] - info: NodeBB Ready 27/4 18:10 [67459] - info: NodeBB Ready 27/4 18:10 [67458] - info: Enabling 'trust proxy' 27/4 18:10 [67459] - info: Enabling 'trust proxy' 27/4 18:10 [67458] - info: NodeBB is now listening on: 0.0.0.0:4568 27/4 18:10 [67459] - info: NodeBB is now listening on: 0.0.0.0:4569
-
Dang, no idea why that would happen. Is everything else working?
-
Yeah, incoming PR. So weird.