connect to redis after startup?

79 views
Skip to first unread message

Caleb Olin

unread,
May 22, 2014, 2:53:46 PM5/22/14
to action...@googlegroups.com
Hello all!

I'm building an app that gets Redis login information from an external API. Is it possible to configure the connection post-startup? I know I can pass config changes in via actionhero.start, but I won't have access to the connection info until I've made that external request.

Evan Tahler

unread,
May 22, 2014, 5:40:30 PM5/22/14
to Caleb Olin, action...@googlegroups.com
No, unfortunately that's a bit of a catch-22.  A number of internal actionhero processes require a redis connection (faye, cache, stats, etc), and won't boot without being able to connect.  

I would suggest writing another script (outside of actionhero) to get that connection info and build the config/redis.js file first.

--
 Evan Tahler
 412.897.6361
 evant...@gmail.com



On Thu, May 22, 2014 at 11:53 AM, Caleb Olin <caleb...@gmail.com> wrote:
Hello all!

I'm building an app that gets Redis login information from an external API. Is it possible to configure the connection post-startup? I know I can pass config changes in via actionhero.start, but I won't have access to the connection info until I've made that external request.

--
You received this message because you are subscribed to the Google Groups "actionHero.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to actionhero-j...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Caleb Olin

unread,
May 23, 2014, 9:15:04 AM5/23/14
to action...@googlegroups.com, Caleb Olin
Could I boot with fakeredis:true, then reset api.config.redis and api.redis later, after retrieving the connection info? Or will that get me into trouble with the internal processes?

Evan Tahler

unread,
May 23, 2014, 12:52:01 PM5/23/14
to Caleb Olin, action...@googlegroups.com
It might work for some use cases but I can't recommend it. 

You'll run into race conditions where maybe you get a client request before you have fully swapped redis connections, or a task worker is mid-job.  You'll also have to re-init the Faye connection and the worker startup behavior, as they both read state from redis at boot. 


--

Caleb Olin

unread,
May 30, 2014, 5:17:15 PM5/30/14
to action...@googlegroups.com, caleb...@gmail.com
We ended up writing a standalone cache module that mimics AH's api.cache, but has some extra sugar to manage multiple connections. We left api.cache alone so we won't mess with internal processes. 
To unsubscribe from this group and stop receiving emails from it, send an email to actionhero-js+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages