Skip to content
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

[HttpWorker]Expand environment variables specified in startup command #5692

Closed
anthonychu opened this issue Feb 21, 2020 · 7 comments · Fixed by #6064
Closed

[HttpWorker]Expand environment variables specified in startup command #5692

anthonychu opened this issue Feb 21, 2020 · 7 comments · Fixed by #6064

Comments

@anthonychu
Copy link
Member

Some startup commands require FUNCTIONS_HTTPWORKER_PORT to be passed to it. Couldn't find a way to do this. The following doesn't seem to work:

"httpWorker": {
	"description": {
		"defaultExecutablePath": "php",
		"defaultWorkerPath": "worker.php",
		"arguments": [
			"-S",
			"0.0.0.0:$FUNCTIONS_HTTPWORKER_PORT"
		]
	}
}
@pragnagopa
Copy link
Member

Overriding FUNCTIONS_HTTPWORKER_PORT would not work when running in Azure due to sandbox restrictions and also to avoid a port that is already in use.

For running HttpWorker standalone and locally, you can set the environment.

Can you please add more details on the scenario setting port would be useful?

@anthonychu
Copy link
Member Author

I meant provide the ability to pass the port that was selected by the host to the startup command as an argument (or part of an argument). Currently what I have put above doesn't seem to work work.

@pragnagopa
Copy link
Member

Ahh, I think it would be useful to support expanding environment variables provided in the start up command.

@pragnagopa pragnagopa modified the milestones: Active Questions, Triaged Feb 21, 2020
@pragnagopa pragnagopa changed the title [HttpWorker]Provide a way to pass FUNCTIONS_HTTPWORKER_PORT to startup command [HttpWorker]Expand environment variables specified in startup command Feb 21, 2020
@anthonychu anthonychu added the P1 label Mar 24, 2020
@fabiocav fabiocav modified the milestones: Triaged, Functions Sprint 76 May 13, 2020
@pragnagopa
Copy link
Member

pragnagopa commented May 20, 2020

PR is now open that supports expanding environment variables provided in httpWorker section using %EnvVarName% notation. Example:

"httpWorker": {
	"description": {
		"defaultExecutablePath": "%TestEnv%",
		"defaultWorkerPath": "%TestEnv%",
		"arguments": [
			"-S",
			"0.0.0.0:%TestEnv%"
		],
               "workerArguments": [
			"0.0.0.0:%TestEnv%"
		]
	}
}

Note: Added workerArguments element to differentiate between, exe args and worker args

@anthonychu
Copy link
Member Author

Thanks! Will this work for Linux as well using the same notation?

Do you have an example of how workerArguments will work? For instance, will the command that is executed be something like:

execPath arg1 arg2 workerPath workerArg1 workerArg2

@pragnagopa
Copy link
Member

Will this work for Linux as well using the same notation?

Yes. It should work on linux as well. Some discussion here: dotnet/runtime#25792

For workerArguments, yes what you provided will be the command used to launch.

  • List in arguments will be appended after defaultExecutablePath but before defaultWorkerPath
  • List in workerArguments will be appended after defaultWorkerPath
"httpWorker": {
	"description": {
		"defaultExecutablePath": "exe/runtime such as node, dotnet etc.",
		"defaultWorkerPath": "worker for the exe provided",
		"arguments": [
			"arg1",
			"arg2"
		],
               "workerArguments": [
			"workerArg1",
                        "workerArg2"
		]
	}
}

@pragnagopa
Copy link
Member

cc @yojagad

@ghost ghost locked as resolved and limited conversation to collaborators Jul 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants