0

I'm using SyncedCron to call a script written in R using Npm.require('child_process'). It works fine on my local, I've worked out the relative path between the script and the bit of the .meteor folder where it gets called from.

This breaks in production though because the app gets bundled and the path changes. I'm also using MUP to deploy to Amazon, and as far as I can see it doesn't take the r script with it.

Are there any neat solutions to deploying non-node bits of code with Meteor?

Jim
  • 521
  • 8
  • 14

1 Answers1

2

Good question. Here is my idea below.

  1. Have you installed R on Amazon? If so and you use UNIX system like Ubuntu, use whereis to get the path to execute R on Amazon

  2. For your R script, store it in the /private folder and use Assets

All files inside a top-level directory called private are only accessible from server code and can be loaded via the Assets API. This can be used for private data files and any files that are in your project directory that you don't want to be accessible from the outside.

Assets allows server code in a Meteor application to access static server assets, which are located in the private subdirectory of an application's tree. Assets are not processed as source files and are copied directly into your application's bundle.

Static server assets are included by placing them in the application's private subdirectory. For example, if an application's private subdirectory includes a directory called nested with a file called rScript.txt inside it, then server code can read rScript.txt by running:

var rScript = Assets.getText('nested/rScript.txt');

You can then pass the script along as input when you execute it on the server.

(ref)

FullStack
  • 5,902
  • 4
  • 43
  • 77