Skip to content

Commit

Permalink
bugfix in the generation of the script
Browse files Browse the repository at this point in the history
  • Loading branch information
MatDau committed May 2, 2020
1 parent 7bafe3a commit 09de1de
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,8 @@ class FLYGenerator extends AbstractGenerator {
switch env {
case "aws":{
return '''
Runtime.getRuntime().exec("chmod +x src-gen/«call.target.name»_undeploy.sh");
ProcessBuilder __processBuilder_undeploy_«call.target.name» = new ProcessBuilder("/bin/bash", "-c", "src-gen/«call.target.name»_undeploy.sh «user» «call.target.name» "+__id_execution);
Runtime.getRuntime().exec("chmod +x src-gen/«call.target.name»_«call.environment.name»_undeploy.sh");
ProcessBuilder __processBuilder_undeploy_«call.target.name» = new ProcessBuilder("/bin/bash", "-c", "src-gen/«call.target.name»_«call.environment.name»_undeploy.sh «user» «call.target.name» "+__id_execution);
Map<String, String> __env_undeploy_«call.target.name» = __processBuilder_undeploy_«call.target.name».environment();

__processBuilder_undeploy_«call.target.name».redirectOutput(ProcessBuilder.Redirect.INHERIT);
Expand All @@ -427,7 +427,7 @@ class FLYGenerator extends AbstractGenerator {
__p_undeploy_«call.target.name»= __processBuilder_undeploy_«call.target.name».start();
__p_undeploy_«call.target.name».waitFor();
if(__p_undeploy_«call.target.name».exitValue()!=0){
System.out.println("Error in «call.target.name»_undeploy.sh ");
System.out.println("Error in «call.target.name»_«call.environment.name»_undeploy.sh ");
System.exit(1);
}
} catch (Exception e) {
Expand All @@ -437,8 +437,8 @@ class FLYGenerator extends AbstractGenerator {
}
case "aws-debug":{
return '''
Runtime.getRuntime().exec("chmod +x src-gen/«call.target.name»_undeploy.sh");
ProcessBuilder __processBuilder_undeploy_«call.target.name» = new ProcessBuilder("/bin/bash", "-c", "src-gen/«call.target.name»_undeploy.sh «user» «call.target.name» "+__id_execution);
Runtime.getRuntime().exec("chmod +x src-gen/«call.target.name»_«call.environment.name»_undeploy.sh");
ProcessBuilder __processBuilder_undeploy_«call.target.name» = new ProcessBuilder("/bin/bash", "-c", "src-gen/«call.target.name»_«call.environment.name»_undeploy.sh «user» «call.target.name» "+__id_execution);
Map<String, String> __env_undeploy_«call.target.name» = __processBuilder_undeploy_«call.target.name».environment();

__processBuilder_undeploy_«call.target.name».redirectOutput(ProcessBuilder.Redirect.INHERIT);
Expand All @@ -452,7 +452,7 @@ class FLYGenerator extends AbstractGenerator {
__p_undeploy_«call.target.name»= __processBuilder_undeploy_«call.target.name».start();
__p_undeploy_«call.target.name».waitFor();
if(__p_undeploy_«call.target.name».exitValue()!=0){
System.out.println("Error in «call.target.name»_undeploy.sh ");
System.out.println("Error in «call.target.name»_«call.environment.name»_undeploy.sh ");
System.exit(1);
}
} catch (Exception e) {
Expand All @@ -474,6 +474,7 @@ class FLYGenerator extends AbstractGenerator {
def deployFlyFunctionOnCloud(FlyFunctionCall call) {
var environment = (call.environment.right as DeclarationObject).features.get(0).value_s
var env_name = call.environment.name
println(deployed_function)
if (!deployed_function.get(environment).contains(call.target.name)){
deployed_function.get(environment).add(call.target.name)
Expand All @@ -485,7 +486,7 @@ class FLYGenerator extends AbstractGenerator {
__termination_deploy_on_cloud.add(__thread_pool_deploy_on_cloud.submit( new Callable<Object> (){
@Override
public Object call() throws Exception{
Runtime.getRuntime().exec("chmod +x src-gen/«call.target.name»_«environment»_deploy.sh");
Runtime.getRuntime().exec("chmod +x src-gen/«call.target.name»_«env_name»_deploy.sh");
ProcessBuilder __processBuilder_deploy_«call.target.name» = new ProcessBuilder("/bin/bash", "-c", "src-gen/«call.target.name»_«environment»_deploy.sh «user» «call.target.name» "+__id_execution);
__processBuilder_deploy_«call.target.name».redirectOutput(ProcessBuilder.Redirect.INHERIT);
Map<String, String> __env_deploy_«call.target.name» = __processBuilder_deploy_«call.target.name».environment();
Expand All @@ -499,7 +500,7 @@ class FLYGenerator extends AbstractGenerator {
__p_deploy_«call.target.name» = __processBuilder_deploy_«call.target.name».start();
__p_deploy_«call.target.name».waitFor();
if(__p_deploy_«call.target.name».exitValue()!=0){
System.out.println("Error in «call.target.name»_«environment»_deploy.sh ");
System.out.println("Error in «call.target.name»_«env_name»_deploy.sh ");
System.exit(1);
}
} catch (Exception e) {
Expand All @@ -515,7 +516,7 @@ class FLYGenerator extends AbstractGenerator {
__termination_deploy_on_cloud.add(__thread_pool_deploy_on_cloud.submit( new Callable<Object> (){
@Override
public Object call() throws Exception{
«call.environment.name».publishFunction("«call.target.name»","src-gen/«call.target.name»_«environment»_deploy.sh");
«call.environment.name».publishFunction("«call.target.name»","src-gen/«call.target.name»_«env_name»_deploy.sh");
return null;
}
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class FLYGeneratorJs extends AbstractGenerator {
int time = 0
FunctionDefinition root = null
Resource resourceInput
String env_name=""
var id_execution = null
var user = ""
HashMap<String, HashMap<String, String>> typeSystem = null
Expand All @@ -73,6 +74,7 @@ class FLYGeneratorJs extends AbstractGenerator {
this.typeSystem=scoping
this.resourceInput = input
this.id_execution = id
this.env_name = environment.name
if(!local){
this.env = (environment.right as DeclarationObject).features.get(0).value_s
this.user = (environment.right as DeclarationObject).features.get(1).value_s
Expand Down Expand Up @@ -133,8 +135,8 @@ class FLYGeneratorJs extends AbstractGenerator {
override doGenerate(Resource input, IFileSystemAccess2 fsa, IGeneratorContext context) {
//fsa.generateFile(name + ".js", input.compileJS(root, env));
println("JS GENERATOR" + typeSystem.get(root.name))
fsa.generateFile(root.name +"_"+ env +"_deploy.sh",input.compileScriptDeploy(root.name,false));
fsa.generateFile(root.name +"_"+ env +"_undeploy.sh",input.compileScriptUndeploy(root.name,false));
fsa.generateFile(root.name +"_"+ env_name +"_deploy.sh",input.compileScriptDeploy(root.name,false));
fsa.generateFile(root.name +"_"+ env_name +"_undeploy.sh",input.compileScriptUndeploy(root.name,false));
if (this.isLocal) {
fsa.generateFile(root.name + ".js", input.compileJavaScript(root.name, true))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class FLYGeneratorPython extends AbstractGenerator {
String user = null
Resource resourceInput
boolean isLocal
boolean isAsync
boolean isAsync
String env_name=""
var list_environment = new ArrayList<String>(Arrays.asList("smp","aws","aws-debug","azure"));
ArrayList listParams = null
List<String> allReqs=null
Expand All @@ -79,6 +80,7 @@ class FLYGeneratorPython extends AbstractGenerator {
root = func
typeSystem = scoping
id_execution = id
env_name=environment.name
if (!local) {
env = (environment.right as DeclarationObject).features.get(0).value_s
user = (environment.right as DeclarationObject).features.get(1).value_s
Expand Down Expand Up @@ -121,8 +123,8 @@ class FLYGeneratorPython extends AbstractGenerator {
}else {
if(env.equals("aws-debug"))
fsa.generateFile("docker-compose-script.sh",input.compileDockerCompose())
fsa.generateFile(root.name +"_"+ env +"_deploy.sh", input.compileScriptDeploy(root.name, false))
fsa.generateFile(root.name +"_"+ env + "_undeploy.sh", input.compileScriptUndeploy(root.name, false))
fsa.generateFile(root.name +"_"+ env_name +"_deploy.sh", input.compileScriptDeploy(root.name, false))
fsa.generateFile(root.name +"_"+ env_name + "_undeploy.sh", input.compileScriptUndeploy(root.name, false))
}
}

Expand Down

0 comments on commit 09de1de

Please sign in to comment.