user1505103
user1505103

Reputation: 33

Meteor - Create a file to be downloaded (without triggering meteor to restart)

I want to create a file and then serve it using Meteor, but I don't want the server to restart when I create/update the file in the public directory.

The user will click on a button to create a config file on the server and I want the user to be able to download that config file.

Is there a way to do this without triggering the server to restart?

I have tried creating a link to the file and creating a hidden file but nothing has worked.

Thanks for your time.

Upvotes: 2

Views: 687

Answers (3)

William Ledoux
William Ledoux

Reputation: 146

If you doesn't want to run in production mode, here is a workaround:

  1. In order to prevent reloading, you have to generate your files in a folder that is located outside of your project's repository.
  2. Then you will have your meteor app to serve the content of that folder.

Here is an example that uses the connect npm repository to make your local folder /meteor/generated_files served under the url hostname.com/downloads/:

var connect = Npm.require('connect');
var fs = Npm.require('fs');

function serveFolder(urlPath, diskPath){
    if(!fs.existsSync(diskPath))
        return false;
    RoutePolicy.declare(urlPath, 'network');
    WebApp.connectHandlers.use(urlPath, connect.static(diskPath));
    return true;
}

serveFolder('/downloads', '/meteor/generated_files/');

I published the very primitive package I have that does just that.

Upvotes: 0

nrw
nrw

Reputation: 819

Try meteor run --production. That might solve your problem.

Upvotes: 3

Nachiket
Nachiket

Reputation: 6177

Server restarts because you are running it in Development mode, When it runs in production, it doesn't restart on content changes.

To run in production, only way I know is, after bundling application,
Have a look here: http://docs.meteor.com/#deploying

Upvotes: 0

Related Questions