Search code examples
azurephantomjsazure-web-rolesazure-worker-roles

PhantomJS Webserver exe on Azure Web Role Startup


I am trying to launch a local webserver instance of PhantomJs on a Azure Web (or Worker) Role to use with HighCharts for rendering server side charting images.

PhantomJs comes as just a simple .exe that can be launched as a webserver with the following command:

phantomjs highcharts-convert.js -host 127.0.0.1 -port 3003

... and then local HTTP POST requests can be made against it.

I have included this command in a startup.cmd batch script that is configured to execute with my Azure Web Role when published via ServiceDefinition.csdef:

<Startup>
  <Task commandLine="startup.cmd" executionContext="elevated" taskType="background" />
</Startup>

startup.cmd:

START phantomjs highcharts-convert.js -host 127.0.0.1 -port 3003

EXIT /B 0

From what I can tell, this appears to execute fine on startup, however, the process does not stay running. It just executes and closes. For example, I can remote into the box, find the deployment and execute startup.cmd manually (in which a command window opens and stays open), and everything works fine.

How do I execute the PhantomJs exe webserver upon instance startup to where it continues running and does not close?

I have tried setting taskType to simple and background in the ServiceDefinition.csdef declaration, yet it doesn't seem to change anything.


Solution

  • Turns out that I did not have the supporting .js files set to "Copy To Output Directory", so the startup.cmd could not find them.

    Thanks to Steve for the output logging suggestion, which allowed me to see the error that it could not find "highcharts-convert.js".