make 5G test user quota
[cloudstore.git] / gearman / send_file.pl
index c1354cb..a3eabd6 100755 (executable)
@@ -13,6 +13,7 @@ use Data::Dump qw(dump);
 
 use lib '/srv/cloudstore/lib';
 use CloudStore::API;
+use WarnColor;
 
 my $api = CloudStore::API->new('s1');
 
@@ -20,8 +21,20 @@ use Gearman::Worker;
 my $worker = Gearman::Worker->new;
 $worker->job_servers('127.0.0.1:4730');
 
-open(my $log, '>>', '/rsync1/s1/log/send_file.log');
-select($log); $|++;
+=head2 create_user
+
+=cut
+
+$worker->register_function( create_user => sub {
+       my ($job) = @_;
+
+       my $work = $job->arg;
+       chomp $work;
+       warn "# create_user [$work]\n";
+       my ( $email, $password, $quota ) = split(/\s+/,$work,3);
+       $quota ||= 200000 && warn "default quota";
+       $api->create_user( $email, $password, $quota );
+});
 
 =head2 send_file ~u2001/from.txt#~u2003/dir/new to.txt
 
@@ -104,11 +117,5 @@ $worker->register_function( user_usage => sub {
 
 warn "$0 pid $$ waitng for jobs\n";
 
-if ( $ENV{SLICE} ) {
-       chroot $ENV{SLICE} || die "can't chroot $ENV{SLICE}: $!";
-} else {
-       warn "WARNING: not running under chroot SLICE=/hostname/sx\n";
-}
-
 $worker->work while 1;