简体   繁体   English

我应该如何使用外部脚本构建Meteor项目?

[英]How should I structure a Meteor project with external scripts?

I'm curious if anyone has developed a best practice for organizing Meteor applications that contain external shell scripts, or other back-end processes that happen outside of the node.js server code and the client side js code. 我很好奇是否有人开发了组织包含外部shell脚本的Meteor应用程序的最佳实践,或者在node.js服务器代码和客户端js代码之外发生的其他后端进程。

For instance, I have a meteor app that is structured like this: 例如,我有一个流程应用程序,其结构如下:

project-name
  client
  lib
  models
  packages
  public
  server

I have a shell script that processes some external data sources, and a Python script that does some other heavy lifting. 我有一个处理一些外部数据源的shell脚本,以及一个执行其他繁重操作的Python脚本。 These all then help by inserting new data into the Mongo instance. 这些都可以通过将新数据插入Mongo实例来提供帮助。 Yes, I know that's a bit of a jumble, but so are the backend data systems. 是的,我知道这有点混乱,但后端数据系统也是如此。 My question is should I put these sorts of projects within the meteor app folder, or should they live outside of the system? 我的问题是我应该将这些类型的项目放在meteor app文件夹中,还是应该在系统之外? Just curious how others are structuring apps like this. 只是好奇其他人如何构建这样的应用程序。

Option #1 选项1

project-name
  client
  ...
  server
    data-processor.sh
    other-utility.py

Option #2 选项#2

project-name
  client
  ...
  private
    data-processor.sh
    other-utility.py

Option #3 选项#3

bin
  data-processor.sh
  other-utility.py
meteor-project-name
  client
  ...
  private

You shouldn't put any non-meteor files inside your meteor project directory, all of those CAN be picked up by some package, even if standard meteor-platform packages don't recognize the extension. 你不应该在你的流星项目目录中放置任何非流星文件,所有这些都可以通过某些软件包获取,即使标准的meteor-platform软件包无法识别扩展名。 So putting them in the /server might cause problems in the future. 因此将它们放入/server可能会在将来引起问题。 The /private folder on the other hand is meant for resources used by your application, so placing the scripts there is unsemantic and inelegant. 另一方面, /private文件夹用于应用程序使用的资源,因此将脚本放在那里是非语义和不优雅的。

To avoid moving those scripts outside of the project folder you can store them inside a hidden directory, that is any directory with name starting with a dot, ie /.scripts . 为了避免将这些脚本移到项目文件夹之外,您可以将它们存储在一个隐藏目录中,即名称以点开头的任何目录,即/.scripts Files placed there will not be picked up by Meteor application. 放置在那里的文件将不会被Meteor应用程序选中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM