Correct BUNDLE_PATH for regular meteor deploy?
mccormjt opened this issue · comments
Hi great pkg!
Cant figure out the correct BUNDLE_PATH value for a normal "meteor deploy"?
I feel like a good number of people are first going to try their sites on the meteor servers first and need to know this value?
Ive tried:
- not setting it at all
- "/built_app"
- process.env.PWD
- process.cwd()
- "/var/www/app/bundle"
Thanks!
So I have figured out that this code:
var meteor_root = Npm.require('fs').realpathSync( process.cwd() + '/../' );
var application_root = Npm.require('fs').realpathSync( meteor_root + '/../' );
process.env.BUNDLE_PATH = application_root;
Succeeds in finding the "bundle root" and in conjunction with your:
ROOT = path.join(process.env.BUNDLE_PATH, 'programs', 'server', 'assets', 'app')
This does find the correct "assets root for the private directory."
I verified, outside of your email package and independently, that Npm FS by itself could indeed find one of my email teplates in the private directory on a deployed meteor node using:
file = path.join(application_root, 'programs', 'server', 'assets', 'app')
Npm.require('fs').readFileSync(file, { encoding: 'utf8' });
The above worked by itself.
However when I set:
process.env.BUNDLE_PATH = application_root;
If still fails to send emails on a regular deployed meteor node.
I should also note that it works completely fine on localhost so everything else should be setup correctly.
I was using this thread to help me with the FS:
http://stackoverflow.com/questions/18378809/find-absolute-base-path-of-the-project-directory-after-meteor-0-6-5
Also I am not getting any errors.....Meiler.send(...) just returns "false"
I think I may have diagnosed the problem.....your Util script runs before I am able to set the BUNDLE_PATH variable. Although....I am not quite sure how to fix this. How am I supposed to run code before you package?
One idea would be to put the BUNDLE_PATH variable in your "config" options for Mailer.config.
What do you think?
Here is my hard coded solution that replaces how you set your ROOT variable in your util script:
(works for me)
if process.env.NODE_ENV == 'development'
In development, using pwd is fine. Remove the .meteor/foo/bar stuff though.
realPath = process.cwd().replace(/(.meteor.*)/g, '')
ROOT = path.join(realPath, 'private')
else
meteor_root = fs.realpathSync( process.cwd() + '/../' )
application_root = fs.realpathSync( meteor_root + '/../' )
ROOT = path.join(application_root, 'programs', 'server', 'assets', 'app')
Could you please provide an easier way to set the BUNDLE_PATH?
The solution I provided above works on both dev and meteor production servers without any user effort in configuring the BUNDLE_PATH
It might even work on other servers like modulus (hevnt tried) since it relies on generic path helpers.
Maybe use this as a solution instead? Then people wont have to worry about configuring BUNDLE_PATH.
PR: #39
This should in theory keep in tact the functionality for people who rely on setting BUNDLE_PATH or APP_DIR...but it still works as normal in development mode AND it automates setting the ROOT variable for normal meteor server deploys.
Thanks so much for the investigations! The BUNDLE_PATH
is quite an inconvenience .. I'll check it out and get back to you.
Merged and fixed: http://meteor-emails.meteor.com/emails/preview/sample/johan