Skip to content

Commit

Permalink
Now using new stomp_send keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
ironcamel committed Mar 4, 2012
1 parent feda670 commit f1dc423
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 26 deletions.
4 changes: 2 additions & 2 deletions Makefile.PL
Expand Up @@ -15,15 +15,15 @@ WriteMakefile(
'Dancer' => '1.3080',
'Dancer::Plugin::Cache::CHI' => '0',
'Dancer::Plugin::DBIC' => '0',
'Dancer::Plugin::Stomp' => '0',
'Dancer::Plugin::Stomp' => '1.0100',
'Dancer::Plugin::Passphrase' => '0',
'Data::Dump' => '0',
'DateTime' => '0',
'IPC::Run' => '0',
'JSON' => '0',
'LWP::UserAgent' => '0',
'Math::Random::Secure' => '0',
'Net::Stomp' => '0',
'Net::STOMP::Client' => '0',
'SQL::Translator' => '0.11006',
'Template' => '0',
'Try::Tiny' => '0',
Expand Down
15 changes: 6 additions & 9 deletions environments/development.yml
@@ -1,16 +1,13 @@
# configuration file for development environment

# the logger engine to use
# console: log messages to STDOUT (your console where you started the
# application server)
# file: log message to a file in log/
logger: "console"
logger: console
#logger: file

# the log level for this environement
# core is the lowest, it shows Dancer's core log messages as well as yours
# (debug, warning and error)
#log: "core"
log: "debug"
# core is the lowest, it shows Dancer's core log messages as well as
# debug, warning and error
#log: core
log: debug

# should Dancer consider warnings as critical errors?
warnings: 1
Expand Down
15 changes: 3 additions & 12 deletions environments/production.yml
@@ -1,17 +1,8 @@
# configuration file for production environment
# production configuration

# only log warning and error messsages
log: "warning"

# log message to a file in logs/
logger: "file"

# don't consider warnings critical
log: debug
logger: file
warnings: 0

# hide errors
show_errors: 0

# cache route resolution for maximum performance
route_cache: 1

11 changes: 8 additions & 3 deletions lib/CodeRunner.pm
Expand Up @@ -143,6 +143,7 @@ del '/ajax/problems/:problem_id' => sub {
};

get '/problems/:problem_id' => sub {
debug '*** getting problem ' . param 'problem_id';
my $template = is_admin() ? 'problem_edit' : 'problem';
template $template => {
problem => get_problem(),
Expand All @@ -160,6 +161,7 @@ post '/problems/:problem_id' => sub {
my $problem = get_problem();
my $file = upload 'code_file';
my $run_id = irand(1_000_000_000);
debug "created random run_id: $run_id";
cache_set $run_id => to_json({status => -1});
my $msg = to_json({
run_id => $run_id,
Expand All @@ -171,10 +173,11 @@ post '/problems/:problem_id' => sub {
cb_url => uri_for('/cb')->as_string,
remote => request->remote_address,
}, { utf8 => 1 });
stomp->send({
stomp_send {
destination => config->{queue},
body => $msg,
});
persistent => 'true',
};
template problem => {
is_running => 1,
run_id => $run_id,
Expand All @@ -188,6 +191,8 @@ get '/status/:run_id' => sub { from_json cache_get param 'run_id' };

post '/cb' => sub {
my $run_id = param 'run_id';
return unless $run_id;

my $json = request->body;
cache_set $run_id => $json;

Expand All @@ -196,7 +201,7 @@ post '/cb' => sub {
my $user_id = $data->{user_id};
return unless $user_id;
my $user = schema->resultset('User')->find($user_id);
return unless $user_id;
return unless $user;

$user->add_to_attempts({
problem => $data->{problem},
Expand Down

0 comments on commit f1dc423

Please sign in to comment.