-
Notifications
You must be signed in to change notification settings - Fork 636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Azure Web App hosting #459
Comments
Application used to reproduce the issue (the git history is useful too): https://github.com/aoberoi/azure-hubot The error is visible in the "Log Stream" view of the app from within the Azure Dashboard. In order to trigger the error, you visit the
I've tried to use environment variables |
Actually, setting those environment variables from the Azure dashboard doesn't seem effective. Adding them from the CLI yielded lots more logs to look into. Will take some time to find the right module load: https://gist.github.com/aoberoi/f22ce55759aa8f93ea88e39b22c51571 |
Open question: why doesn't the deploy script use It seems like Azure's node-specific deployment scripts are targeting projects that don't have a Windows-friendly launcher (e.g. make sure |
The most interesting part of the log is in these three lines:
Notice how instead of looking for the 'hubot' module in the "D:\home\site\wwwroot\node_modules", where it would have been found, the |
Update: it turns out the deployment (which is basically the copying of files from the git repo to a wwwroot directory) is not the issue at all. KudoSync is one part of the deployment. It seems to be an issue with iisnode and how node is executed in that environment. |
I think I've gained some understanding after reading the following file: https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config In iisnode there's the concept of an interceptor, which is an application that runs instead of the target application. It sounds like this file would be treated as the main module in the node process, and therefore The question this creates is: Can we override this interceptor to be a part of the Azure Web App site? |
Even if there's a successful workaround with setting our own interceptor, there's some serious limitations to iisnode. It looks like long running processes are just not considered a use case fit for iisnode: tjanczuk/iisnode#569. This would result in many hubot processes being spawned and killed, which means the websocket connection would frequently be opened and closed, or potentially more than one concurrent connection being open at a time. I can see lots of undeterministic issues in this scenario. Relevant: https://docs.microsoft.com/en-us/azure/architecture/best-practices/background-jobs. It looks like WebJobs is actually a better fit. It seems relatively easy to get going (especially considering the Update: OOooOO It looks like forwarding requests is very much possible: https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#network-endpoint-listening. |
Was this ever resolved? I am able to work around the issue with the answer here, and tell my app to additionally look at wwwroot\node_modules module dependencies. Curious if there is a better way as I'm trying to learn. |
@dude0001 i haven't tried the workaround you mentioned, and i'm glad its working for at least a couple people. however, this only solves the loading dependencies problem, and not the bigger issue described above:
i think a better workaround would be to choose Linux as the platform for this app, now available on Azure, since it gets you away from iisnode. we still haven't tried to implement this with Azure WebJobs, but that would be the way to fix this issue and still run on Windows. |
Do you think there are still issues with this configuration? If so, I'd be interested in contributing to using web jobs. Do you have any direction or tasks that need to be done? I have the iisnode setting nodeprocesscountperapplication set to one to limit the web app to one instance. I then have the Always On option enabled in the web app itself. |
@dude0001 thanks for point out these settings, i wasn't aware! the combination of these two settings would indeed satisfy all my current concerns. of course, i can't speak from experience of running a hubot instance with these, so if you're willing to do this and report back any issues, we would be very grateful. specifically, the nodeProcessCountPerApplication sounds like it would keep the hubot application limited to one process when sent to 1, which is actually the default, so that's great! also, the Always On option would also be necessary if we implemented the application as a WebJob. so it no longer seems to be necessary to work on a alternative of deploying hubot as a WebJob, since that route and the current implementation seem effectively the same. if you'd like to contribute even further, here are a couple ways you can:
|
I've updated the summary of this issue to reflect what we've learned so far. |
Description
Azure-based hosting in App Service's Web Apps (formerly known as Websites) per the official Hubot deployment instructions is currently broken.
After some investigation in #283, we don't yet know if this is specific tohubot-slack
, or if this is an issue with commonly used deployment instructions including the official instructions in hubot's documentation.Workaround info:
The easiest workaround at the moment is to use the Linux platform when creating the environment for your Azure Web App. This eliminates
iisnode
, which we've determined was the root of the issue.If you'd like to still run on the Windows platform, another workaround can be accomplished by setting a few specific configuration options. Thanks to @dude0001 for finding and sharing this!
NODE_PATH
environment variable according to this answerThis issue will help organize the tasks related to further investigate and resolve this issue, and improve the experience of deploying Hubot to Azure. We will close this issue when the instructions above work out of the box, or have an even easier mechanism for users of this adapter specifically.
Subtasks:
Investigate whether issue is resolved by using the Azure CLI 2.0 (instead of the older Azure CLI). This will include using the Azure Resource Management APIs (instead of the Azure Service Management APIs) and building against App Services' Azure Web Apps (instead of Azure Websites).
➡️ No, its not specific to the CLI version. The 1.0 CLI has a helper to generate a deployscript locally, but the 2.0 CLI will generate that same deployscript upon push.
Investigate if there's a way around the creation of
server.js
in the instructions, and if that might resolve the issue loading thehubot
dependency.➡️ The
server.js
file isn't the problem, the problem is that iisnode imposes aninterceptor.js
entry point, andserver.js
(or any application entry point we use) isrequire()
d into the node program instead of being run directly. This forcesrequire.main.require()
to look in the wrong places to load the module: in theinterceptor.js
directory.Research different options for loading the
hubot
dependency (see Use require.main.require 'hubot' instead of require 'hubot' #137, Avoid our devDependencies when requiring 'hubot' #138) and see if they are viable fixes for the issue.➡️ The choice to use
require.main.require()
still seems to be the "right" one, given the circumstances. iisnode is doing the weird, unexpected thing, but there are issues bigger than loading thehubot
dependency that need to be wrangled. iisnode can potentially spawn many node processes, each scoped to an incoming HTTP request (because that's how Azure Web Apps are designed to work). This model is a poor fit for a long-running process like hubot with hubot-slack because we don't want many websocket client connections in distinct processes.Investigate if the issue is resolved by choosing the Linux platform instead of the Windows platform. This could be a short-term fix, but we should still strive for Windows compatibility. Are the same multi-process issues present?
➡️ If you're willing to use the Linux platform, the currently known issues are resilved.
Explore using Azure Web Apps with WebJobs for deployment. Write a script that will copy the source to the appropriate WebJob directory before installing dependencies. Make hubot run in a continuous WebJob. Use a simple dummy entrypoint script that proxies requests to that WebJob, or simply get
interceptor.js
to do that.➡️ Thanks to the workaround found by @dude0001, it seems that this exploration won't actually be necessary. That workaround, summarized above, should be roughly equivalent to running in a WebJob. If you find otherwise, please let us know and we'll update this information.
Create an Azure Resource Management template for Hubot and distribute it in the Microsoft marketplace (see: https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-template-deploy-portal#deploy-resources-from-marketplace).
Contribute updated deployment instructions to hubotio/hubot docs.
Requirements (place an
x
in each of the[ ]
)The text was updated successfully, but these errors were encountered: