{"action":"created","issue":{"url":"https://api.github.com/repos/iojs/io.js/issues/881","labels_url":"https://api.github.com/repos/iojs/io.js/issues/881/labels{/name}","comments_url":"https://api.github.com/repos/iojs/io.js/issues/881/comments","events_url":"https://api.github.com/repos/iojs/io.js/issues/881/events","html_url":"https://github.com/iojs/io.js/pull/881","id":58108608,"number":881,"title":"src: allow vendors to inject functionality at startup","user":{"login":"ofrobots","id":79017,"avatar_url":"https://avatars.githubusercontent.com/u/79017?v=3","gravatar_id":"","url":"https://api.github.com/users/ofrobots","html_url":"https://github.com/ofrobots","followers_url":"https://api.github.com/users/ofrobots/followers","following_url":"https://api.github.com/users/ofrobots/following{/other_user}","gists_url":"https://api.github.com/users/ofrobots/gists{/gist_id}","starred_url":"https://api.github.com/users/ofrobots/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ofrobots/subscriptions","organizations_url":"https://api.github.com/users/ofrobots/orgs","repos_url":"https://api.github.com/users/ofrobots/repos","events_url":"https://api.github.com/users/ofrobots/events{/privacy}","received_events_url":"https://api.github.com/users/ofrobots/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/iojs/io.js/labels/semver-minor","name":"semver-minor","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":46,"created_at":"2015-02-18T18:36:44Z","updated_at":"2015-03-12T16:33:01Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/iojs/io.js/pulls/881","html_url":"https://github.com/iojs/io.js/pull/881","diff_url":"https://github.com/iojs/io.js/pull/881.diff","patch_url":"https://github.com/iojs/io.js/pull/881.patch"},"body":"Here's a proposal, along with a PR, I would like to get feedback from the community on.\r\n\r\nIt would be nice if there was a standard mechanism to allow vendors, such as a cloud host, to customize startup of node applications.\r\n\r\nBasically, I want to be able to inject functionality into a node application without requiring an explicit require. This could be useful to automatically enable, e.g., vendor specific tracing and application performance monitoring APIs when applications are deployed.\r\n\r\nThere are a few ways this could be done:\r\n0. (Status quo) Ask the developers to modify their applications and add an explicit require of a vendor provided npm module. This adds friction to the deployment experience and possibly prevents people from being able to easily try different cloud vendors.\r\n1. The vendor can maintain their own fork of node.js/io.js but with extra functionality added. This package would be offered instead of the standard node.js/io.js packages. This is potentially high overhead for the vendor. Effort may be duplicated by different vendors.\r\n2. Build a standard mechanism into node.js/io.js that allows vendors to inject some functionality into the node startup process.\r\n\r\nHere's a proposal on how to do option 2 (EDIT: updated as per suggestions by @piscisaureus):\r\n* ~~On startup, node checks if `process.env.NODE_VENDOR_STARTUP` is set. If so, the file `node_prefix + '/lib/vendor/index.js'` is loaded (if it exists).~~\r\n* ~~Vendors could package up their distributions of node/io by adding lib/vendor.~~\r\n~~Another alternative would be for `NODE_VENDOR_STARTUP` to be a path. It gives more flexibility, but is probably not as secure.~~\r\n\r\n```\r\nexport NODE_PRELOAD=foo,/bar/baz.js,quux\r\n```\r\ntranslates to:\r\n```javascript\r\nrequire('foo');\r\nrequire('/bar/baz.js');\r\nrequire('quux');\r\n```\r\n\r\nThoughts?"},"comment":{"url":"https://api.github.com/repos/iojs/io.js/issues/comments/78518664","html_url":"https://github.com/iojs/io.js/pull/881#issuecomment-78518664","issue_url":"https://api.github.com/repos/iojs/io.js/issues/881","id":78518664,"user":{"login":"chrisdickinson","id":37303,"avatar_url":"https://avatars.githubusercontent.com/u/37303?v=3","gravatar_id":"","url":"https://api.github.com/users/chrisdickinson","html_url":"https://github.com/chrisdickinson","followers_url":"https://api.github.com/users/chrisdickinson/followers","following_url":"https://api.github.com/users/chrisdickinson/following{/other_user}","gists_url":"https://api.github.com/users/chrisdickinson/gists{/gist_id}","starred_url":"https://api.github.com/users/chrisdickinson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrisdickinson/subscriptions","organizations_url":"https://api.github.com/users/chrisdickinson/orgs","repos_url":"https://api.github.com/users/chrisdickinson/repos","events_url":"https://api.github.com/users/chrisdickinson/events{/privacy}","received_events_url":"https://api.github.com/users/chrisdickinson/received_events","type":"User","site_admin":false},"created_at":"2015-03-12T16:33:01Z","updated_at":"2015-03-12T16:33:01Z","body":"@trevnorris I'm not convinced it needs to go into core (vs. an npm package that provides a wrapper, or needs to be baked in by providers at an individual level.) Working a larger response."}}