Skip to content

Instantly share code, notes, and snippets.

@robksawyer
Created June 1, 2015 06:39
Show Gist options
  • Select an option

  • Save robksawyer/ac9fd4a7b953ca611f2c to your computer and use it in GitHub Desktop.

Select an option

Save robksawyer/ac9fd4a7b953ca611f2c to your computer and use it in GitHub Desktop.
Garbly gook
uploader.createZipAndUploadToS3(fileStream, settings.aws_s3_project_bucket).then(
function(fileData){
sails.log('Promised fullfilled.');
sails.log.info(fileData);
//Create the file record to store details about the file
uploader.createFileRecord(req.user.id, fileStream, fileData).then(
function(fileRecord){
sails.log('File record saved.');
sails.log(fileRecord.id);
//Create a work queue and retrieve the name to pass along to the job record.
amazon.createSQSWorkQueue(req.user.id, req.param('name'), settings.aws_s3_render_bucket).then(
function(queueRecord){
sails.log('Amazon SQS work queue created!');
sails.log(queueRecord);
//Create and save the job to the database
Jobs.create({
name: req.param('name'),
files: [fileRecord.id],
owner: req.user.id,
animation_start_frame: req.param('animation_start_frame'),
animation_end_frame: req.param('animation_end_frame'),
animation_total_frames: req.param('animation_end_frame') - req.param('animation_start_frame') + 1,
ami_id: req.param('ami_id'),
instance_type: req.param('instance_type'),
aws_ec2_region: req.param('aws_ec2_region'),
aws_sqs_region: req.param('aws_sqs_region'),
aws_ec2_instance_count: req.param('aws_ec2_instance_count'),
max_spend_amount: req.param('max_spend_amount'),
queue: queueRecord.id
}).exec(function createJob(err, jobData){
if(err){
sails.log.error(err);
return res.negotiate(err);
}
sails.log('Created a job with the name ' + jobData.name);
req.flash('success', 'Spot instance job ' + jobData.name + ' created successfully!');
res.redirect('jobs/submit/' + jobData.id);
});
},
function(err){
sails.log.error(err);
return res.negotiate(err);
}
);
},
function(err) {
sails.log.error(err);
return res.negotiate(err);
}
);
},
function(err){
sails.log.error(err);
return res.negotiate(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment