Chef: How to subscribe to any file in a directory? - resources

While it is rather easy to subscribe a chef provider to a single file (e.g. subscribes :restart, 'template[/etc/daemon/foo.conf], I am struggling to find some mechanism where I can subscribe to any file in a directory. Basically, what I am looking for is some sort of regex/wildcard matching, like subscribes :restart, 'template[/etc/daemon/*].
The use case here is a conf.d mechanism, so I want to reload php after any new file is placed in /etc/php/conf.d. I can not use notifies from the recipe, since I do not know in the respective php modules if there is just php-cli, php-fpm or mod_php with apache to notify.
The only way I can come up with is creating some weird hack, like modifying an arbitrary /etc/php/modulelist.txt by each php module, and subscribing to that one, but maybe there is a better/nicer way using Chef.

Related

Prevent 3rd party extension from sending messages to my extension / add filter to runtime.onConnectExternal and runtime.onMessageExternal

I have 2 extensions that must communicate with each other over runtime.sendMessage / runtime.connect. However, I worry that this exposes a gateway for foreign extensions to try to communicate with our own. I know I can just check for the sender inside the event handlers. Nonetheless, I still fear that if another extension starts spamming my own it may create havoc. I would rather find a way to completely ban an extension that behaves this way from communicating with ours.
Does anyone have a clue how to achieve this?

Changing operation flow in nodejs

I am trying to create an ecommerce website in nodejs.I want it to be modular so that we can add extensions later without editing the main codebase. For example suppose I have an extension which checks if a user is requester or approver, and if he is an approver he can checkout, otherwise a approval request will be sent to corresponding approver.Suppose I emit an event when a checkout is made, then that extension can catch it and process it. But at the same time I want the normal flow to be changed. How can I do that? Should I create a checkout module extending original checkout module and override functions and make sure that extension's module is loaded ? If I do it there will be problem if two different extensions are adding features to same core module.What is the best way to do it ?
Generally speaking, there are two ways widely used to extend a web app :
Webhooks
Api
Both have their pros and cons.
What you are trying to do is possible in hook style, because the code will be execute on the server itself and you can extend some objects and modify their behavior as you want.

Logstash Config file at an endpoint

Is there a way to have the logstash config file be served from a HTTP endpoint?
I want to be able to share the configs from say a S3 bucket endpoint...
And just want to have them in one place.
I thought I saw somewhere I could...but cannot find it in the docs-
Thanks
It is little* unsecure to change your configs from web end-point...
But just for sake of curiosity you can do it.
You cant use nginx + php-fpm and from php you can call bash script which will perform all what you want!)
Also you must set appropriate file modes.
Maybe this approach little bit sophisticated - but it possible to achieve your aim.
PS: Anyway it is bad practice. Better use something like CodeDeploy or Jenkins etc.

Pubsubhubbub library for NodeJs

I have a system where various rss feeds are added. I want to follow the content and be notified when new content is added in the feeds without having to check them one by one.
I found out there is a pubsubhubbub protocol and that publishers can use various hubs which implement this protocol in their feeds. This is how I found out about superfeedr and I'm trying to work with their XMPP API. I installed their nodejs library and made a few subscribe tests that worked fine.
Is it possible to use the node superfeedr module to subscribe to a feed that doesn't use superfeedr? For example I found one that has:
link rel='hub' href='http://pubsubhubbub.appspot.com/'
Do I have to handle each hub separately or I can just send them the same requests based on the protocol?
Alex, I created Superfeedr.
Yes, of course it is possible to subscribe to a feed that doesn't use Superfeedr. Superfeedr acts as a default hub. You can add any feed, and you should get notifications for it. The only difference is that you may see delays. We poll feeds every 15 minutes, so, unless there are strong caches, you should see messages no later than 15 minutes after they've been published.
2 and 3 are probably not relevant given 1. However, I believe there are a couple other PubSubHubbub libraries, but they all require that your endpoint is outside the firewall... and all of them will only work for feeds that use the pubsubhubbub protocol. Even though your application will use each hub separately, the code should be the same, so that's transparent for you.
I hope this helps.

Get 2 userscripts to interact with each other?

I have two scripts. I put them in the same namespace (the #namespace field).
I'd like them to interactive with another.
Specifically I want script A to set RunByDefault to 123. Have script B check if RunByDefault==123 or not and then have script A using a timeout or anything to call a function in script B.
How do I do this? I'd hate to merge the scripts.
The scripts cannot directly interact with each other and // #namespace is just to resolve script name conflicts. (That is, you can have 2 different scripts named "Link Remover", only if they have different namespaces.)
Separate scripts can swap information using:
Cookies -- works same-domain only
localStorage -- works same-domain only
Sending and receiving values via AJAX to a server that you control -- works cross-domain.
That's it.
Different running instances, of the same script, can swap information using GM_setValue() and GM_getValue(). This technique has the advantage of being cross-domain, easy, and invisible to the target web page(s).
See this working example of cross-tab communication in Tampermonkey.
On Chrome, and only Chrome, you might be able to use the non-standard FileSystem API to store data on a local file. But this would probably require the user to click for every transaction -- if it worked at all.
Another option is to write an extension (add-on) to act as a helper and do the file IO. You would interact with it via postMessage, usually.
In practice, I've never encountered a situation were it wasn't easier and cleaner to just merge any scripts that really need to share data.
Also, scripts cannot share code, but they can inject JS into the target page and both access that.
Finally, AFAICT, scripts always run sequentially, not in parallel. But you can control the execution order from the Manage User Scripts panel

Resources