Skip to content

Instantly share code, notes, and snippets.

@azinneera
Last active August 16, 2019 06:51
Show Gist options
  • Save azinneera/3c00559ea7083837ee9d7d578eb7efc4 to your computer and use it in GitHub Desktop.
Save azinneera/3c00559ea7083837ee9d7d578eb7efc4 to your computer and use it in GitHub Desktop.
// Cell file for Hello world Sample
import ballerina/config;
import celleryio/cellery;
public function build(cellery:ImageName iName) returns error? {
// Hello Component
// This Components exposes the HTML hello world page
cellery:Component helloComponent = {
name: "hello",
source: {
image: "wso2cellery/samples-hello-world-webapp"
},
ingresses: {
webUI: <cellery:WebIngress>{ // Web ingress will be always exposed globally.
port: 80,
gatewayConfig: {
vhost: "hello-world.com",
context: "/"
}
}
},
envVars: {
HELLO_NAME: { value: "World" }
}
};
// Cell Initialization
cellery:CellImage helloCell = {
components: {
helloComp: helloComponent
}
};
return cellery:createImage(helloCell, untaint iName);
}
public function run(cellery:ImageName iName, map<cellery:ImageName> instances) returns error? {
cellery:CellImage helloCell = check cellery:constructCellImage(untaint iName);
string vhostName = config:getAsString("VHOST_NAME");
if (vhostName !== "") {
cellery:WebIngress web = <cellery:WebIngress>helloCell.components.helloComp.ingresses.webUI;
web.gatewayConfig.vhost = vhostName;
}
string helloName = config:getAsString("HELLO_NAME");
if (helloName !== "") {
helloCell.components.helloComp.envVars.HELLO_NAME.value = helloName;
}
return cellery:createInstance(helloCell, iName, instances);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment