My boss just made an executive decision to run our website as one giant Express app, so I'm stuck trying to work out a usable setup given our situation. We have lots of little Express apps (browser games, interactive RPG character sheets, database viewers, etc.) which are completely separate projects with their own Git repositories and app.js
files, and we need to be able to push frequent updates to these apps without reloading the entire server and disconnecting users on the rest of the apps. My current plan is to have an 'apps' folder and have a post-commit script to clone each repo to its own subfolder.
The next step is where I'm stuck. I can clear the require
cache, loop through the apps folder, and require()
apps when the filesystem detects a change, but that won't remove any mounted routes or middleware. I have no control over the subapps, so I can't manually name and remove each route. Is there any way to accomplish this type of setup with Express?
答案 0 :(得分:-1)
考虑到Express的设计方式,我所寻求的解决方案实际上是不可能实现的。我们最终通过http-proxy
设置代理服务器,并在其自己的子域中为每个应用程序提供服务,从而实现了我们想要的热重载,但却迫使我们找到了跨应用程序通信的替代解决方案。