SlideShare uma empresa Scribd logo
1 de 88
dotCloud and go
Una Breve Introduzione a DotCloud




                1
L’immancabile esempio



          2
3
4
5
6
7
8
9
dove lo metto?



      10
COME lo metto?



      11
QUANTO TEMPO
  CI METTO?


     12
dotCloud



   13
14
IaaS - PaaS - SaaS



        15
IaaS - PaaS - SaaS
        15
16
17
18
19
dotcloud



   20
easy_install



     21
Easy Install è un modulo
python (easy_install)
incluso in setuptools che
vi consente di scaricare ed
installare automaticamente
pacchetti Python.

             22
Easy Install è un modulo
python (easy_install)
incluso in setuptools che
vi consente di scaricare ed
installare automaticamente
pacchetti Python.

             23
Sì, Python



    24
(è il motivo per cui
queste slide sono nere)


           25
26
     (-:
Python 2.7



    27
28
     )-:
$ dotcloud create whatever
Created application "whatever"




              29
30
$ cat dotcloud.yml
www:
   type: perl
   approot: www
backend:
   type: perl-worker
   approot: backend
nosqldb:
   type: redis
sqldb:
   type: mysql



          31
$ cat dotcloud.yml
 www:
    type: perl
    approot: www
 backend:
    type: perl-worker
    approot: backend
 nosqldb:
    type: redis
 sqldb:
    type: mysql



32
$ cat dotcloud.yml
     www:
        type: perl
        approot: www
     backend:
        type: perl-worker
        approot: backend
     nosqldb:
        type: redis
     sqldb:
        type: mysql



33
type: perl




    34
$ cat app.psgi
#!/usr/bin/env perl
use Dancer;
use whatever;
dance();




 35
$ cat Makefile.PL
...
  PREREQ_PM => {
     'Test::More' => 0,
     'YAML'        => 0,
     'Dancer'      => 1.3070,
     'Plack::Request' => 0,
     'Template' => 0,
     'JSON' => 0,
     'Redis' => 0,
     ...
  },
...
    36
type: perl-worker




        37
$ cat supervisord.conf
[program:exporter]
command = perl /home/dotcloud/current/bin/exporter

[program:saver]
command = perl /home/dotcloud/current/bin/saver

                         38
$ cat supervisord.conf
[program:exporter]
command = perl /home/dotcloud/current/bin/exporter

[program:saver]
command = perl /home/dotcloud/current/bin/saver


                         39
$ cat supervisord.conf
[program:exporter]
command = perl /home/dotcloud/current/bin/exporter

[program:saver]
command = perl /home/dotcloud/current/bin/saver


                         40
$ cat dotcloud.yml
     www:
        type: perl
        approot: www
     backend:
        type: perl-worker
        approot: backend
     nosqldb:
        type: redis
     sqldb:
        type: mysql



41
Connettersi




     42
43
$ cat /home/dotcloud/environment.yml
DOTCLOUD_ENVIRONMENT: default
DOTCLOUD_NOSQLDB_REDIS_HOST: whatever-polettix.dotcloud.com
DOTCLOUD_NOSQLDB_REDIS_LOGIN: redis
DOTCLOUD_NOSQLDB_REDIS_PASSWORD: ...
DOTCLOUD_NOSQLDB_REDIS_PORT: '13749'
DOTCLOUD_NOSQLDB_REDIS_URL: ...
DOTCLOUD_PROJECT: whatever
DOTCLOUD_SERVICE_ID: 0
DOTCLOUD_SERVICE_NAME: www
DOTCLOUD_SQLDB_MYSQL_HOST: whatever-polettix.dotcloud.com
DOTCLOUD_SQLDB_MYSQL_LOGIN: root
DOTCLOUD_SQLDB_MYSQL_PASSWORD: ...
DOTCLOUD_SQLDB_MYSQL_PORT: '13747'
DOTCLOUD_SQLDB_MYSQL_URL: ...




                             44
use JSON qw< from_json >;
use File::Slurp qw< read_file >;

sub get_dotcloud_config {
   my $filename = shift || '/home/dotcloud/environment.json';
   my $config_text = read_file($filename);
   my $config = from_json($config_text);
   return $config;
} ## end sub get_dotcloud_config




                             45
sub get_redis {
   my $config = get_dotcloud_config();
   my ($password, $hostname, $port) = map {
      $config->{'DOTCLOUD_NOSQLDB_REDIS_' . $_}
   } qw< PASSWORD HOST PORT >;

    require Redis;
    my $redis = Redis->new(server => "$hostname:$port");
    $redis->auth($password);
    return $redis;
}




                              46
ROTFL
sub get_redis {
   my $config = get_dotcloud_config();
   my ($password, $hostname, $port) = map {
      $config->{'DOTCLOUD_NOSQLDB_REDIS_' . $_}
   } qw< PASSWORD HOST PORT >;

    require Redis;
    my $redis = Redis->new(server => "$hostname:$port");
    $redis->auth($password);
    return $redis;
}




                              47
(mi basta poco)



       48
sub get_dbh {
   my $config = get_dotcloud_config();
   my ($username, $password, $hostname, $port) = map {
      $config->{'DOTCLOUD_SQLDB_MYSQL_' . $_}
   } qw< LOGIN PASSWORD HOST PORT >;

    require DBI;
    my $dbh = DBI->connect(
       "dbi:mysql:host=$hostname;port=$port"
          . ";database=whatever",
       $username, $password,
       { RaiseError => 1},
    );
    return $dbh;
}




                              49
50
51
use lib '/home/dotcloud/code/lib';
                52
DotCloud::Environment



          53
54
ora... in produzione



         55
$ dotcloud push whatever
# Found dotcloud.yml: Using /home/poletti/sviluppo/
perl/whatever as a base directory
# upload /home/poletti/sviluppo/perl/whatever ssh://
dotcloud@uploader.dotcloud.com:443/whatever/
branch:master
# git
...
2011-08-27 09:00:16 [api] Deploy whatever scheduled
for revision=latest
2011-08-27 09:00:16 [api] Waiting for the build. (It
may take a few minutes)
2011-08-27 09:00:17 [api] All the services are ready.
Beginning the build.
...




                          56
uso git



   57
potete usare mercurial



          58
oppure niente



      59
io uso git



    60
fatto



  61
$ dotcloud list whatever
whatever:
  - www     (type: perl; instances: 1)
  - nosqldb (type: redis; instances: 1)
  - sqldb   (type: mysql; instances: 1)
  - backend (type: perl-worker; instances: 1)

$ dotcloud url whatever
www: http://www.whatever.dotcloud.com/




                      62
63
$ dotcloud info whatever.backend
build_revision: git-b2f52d5
cluster: wolverine
config: {}
created_at: 1313990084.301964
image_version: b81a3f3949a8 (latest)
ports:
-   name: ssh
    url: ssh://dotcloud@whatever-polettix.dotcloud.com:13750
state: running
type: perl-worker




                             64
telecomando:
dotcloud run


      65
type: mysql
$ dotcloud info whatever.sqldb
cluster: wolverine
config:
    mysql_password: <the-password>
created_at: 1313990083.324873
...

$ dotcloud run whatever.sqldb -- 
    mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ;
or g.
...
mysql> CREATE TABLE weight (...
                         66
troubleshooting?



       67
dotcloud logs
    (Luke!)


      68
$ dotcloud logs whatever.backend
#       tail -F /var/log/supervisor/*.log
==> /var/log/supervisor/exporter-stderr---supervisor-2y6P9O.log <==
[2011/08/27    01:35:25   INFO   ]   serving pending requests if needed...
[2011/08/27    01:35:25   INFO   ]   waiting for more export requests...
[2011/08/27    01:39:20   INFO   ]   serving pending requests if needed...
[2011/08/27    01:39:20   INFO   ]   waiting for more export requests...
[2011/08/27    01:39:42   INFO   ]   got element to export: {"email":"flavio@polettix.it","username":"silvia"}
[2011/08/27    01:42:18   INFO   ]   serving pending requests if needed...
[2011/08/27    01:42:18   INFO   ]   waiting for more export requests...
[2011/08/27    01:42:30   INFO   ]   got element to export: {"email":"flavio@polettix.it","username":"silvia"}
[2011/08/27    09:00:24   INFO   ]   serving pending requests if needed...
[2011/08/27    09:00:24   INFO   ]   waiting for more export requests...


==> /var/log/supervisor/exporter-stdout---supervisor-foI5vi.log <==
==> /var/log/supervisor/saver-stderr---supervisor-pt1_hK.log <==
[2011/08/27    01:35:25   INFO   ]   waiting for more data...
[2011/08/27    01:36:04   INFO   ]   got element to save: {"epoch":1313913600,"weight":83200,"username":"flavio"}
[2011/08/27    01:37:25   INFO   ]   got element to save: {"epoch":1313827200,"weight":62000,"username":"silvia"}
[2011/08/27    01:39:20   INFO   ]   performing initial transfer if needed...
[2011/08/27    01:39:20   INFO   ]   waiting for more data...
[2011/08/27    01:42:18   INFO   ]   performing initial transfer if needed...
[2011/08/27    01:42:18   INFO   ]   waiting for more data...
[2011/08/27    01:44:04   INFO   ]   got element to save: {"epoch":1313913600,"weight":78000,"username":"whatever"}
[2011/08/27    09:00:24   INFO   ]   performing initial transfer if needed...
[2011/08/27    09:00:24   INFO   ]   waiting for more data...


==> /var/log/supervisor/saver-stdout---supervisor-iQDgpA.log <==

==> /var/log/supervisor/supervisord.log <==
2011-08-27    01:42:18,703   INFO     spawned:   'saver' with pid 19587
2011-08-27    01:42:18,713   INFO     spawned:   'exporter' with pid 19588
2011-08-27    01:42:19,914   INFO     success:   saver entered RUNNING state, process has stayed up   for > than 1 seconds (startsecs)
2011-08-27    01:42:19,943   INFO     success:   exporter entered RUNNING state, process has stayed   up for > than 1 seconds (startsecs)
2011-08-27    09:00:22,067   INFO     stopped:   saver (terminated by SIGTERM)
2011-08-27    09:00:22,070   INFO     stopped:   exporter (terminated by SIGTERM)
2011-08-27    09:00:24,079   INFO     spawned:   'saver' with pid 19729
2011-08-27    09:00:24,086   INFO     spawned:   'exporter' with pid 19730
2011-08-27    09:00:25,426   INFO     success:   saver entered RUNNING state, process has stayed up   for > than 1 seconds (startsecs)
2011-08-27    09:00:25,426   INFO     success:   exporter entered RUNNING state, process has stayed   up for > than 1 seconds (startsecs)
                                                                             69
PIÙ troubleshooting?



         70
dotcloud run
   (like hell)


      71
$ dotcloud run whatever.www -- ps afx
# ps afx
  PID TTY     STAT   TIME COMMAND
 3558 ?       S      0:00 sshd: dotcloud@pts/0
 3559 pts/0   Rs+    0:00 _ ps afx
  144 ?       Ss     0:44 /usr/bin/python /usr/
 3495 ?       S      0:00 _ /usr/local/bin/uwsg
 3496 ?       S      0:00      _ /usr/local/bin/




                       72
ANCORA PIÙ
troubleshooting?


       73
dotcloud ssh



     74
dotcloud ssh
 (no root, sorry!)


        75
$ dotcloud ssh whatever.backend
# $SHELL
dotcloud@whatever-default-backend-0:~$

$ dotcloud ssh whatever.nosqldb
# $SHELL
redis@whatever-default-nosqldb-0:~$ redis-cli
redis> auth ...
OK
redis> smembers users
1) "silvia"
2) "flavio"
3) "whatever"

                      76
77
$ git commit
     78
OPPURE



  79
$ dotcloud push --all whatever




               80
$ dotcloud push whatever -b branch




                 81
82
83
È tutto molto triste



         84
85
Account Multipli:
https://github.com/polettix/dotmulti



                 86
87

Mais conteúdo relacionado

Mais procurados

Any event intro
Any event introAny event intro
Any event introqiang
 
Legacy applications - 4Developes konferencja, Piotr Pasich
Legacy applications  - 4Developes konferencja, Piotr PasichLegacy applications  - 4Developes konferencja, Piotr Pasich
Legacy applications - 4Developes konferencja, Piotr PasichPiotr Pasich
 
Perl: Coro asynchronous
Perl: Coro asynchronous Perl: Coro asynchronous
Perl: Coro asynchronous Shmuel Fomberg
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webclkao
 
Smolder @Silex
Smolder @SilexSmolder @Silex
Smolder @SilexJeen Lee
 
Asynchronous I/O in PHP
Asynchronous I/O in PHPAsynchronous I/O in PHP
Asynchronous I/O in PHPThomas Weinert
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Masahiro Nagano
 
Trading with opensource tools, two years later
Trading with opensource tools, two years laterTrading with opensource tools, two years later
Trading with opensource tools, two years laterclkao
 
Hacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from PerlHacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from Perltypester
 
Ethiopian multiplication in Perl6
Ethiopian multiplication in Perl6Ethiopian multiplication in Perl6
Ethiopian multiplication in Perl6Workhorse Computing
 
Operation Oriented Web Applications / Yokohama pm7
Operation Oriented Web Applications / Yokohama pm7Operation Oriented Web Applications / Yokohama pm7
Operation Oriented Web Applications / Yokohama pm7Masahiro Nagano
 
Modern Getopt for Command Line Processing in Perl
Modern Getopt for Command Line Processing in PerlModern Getopt for Command Line Processing in Perl
Modern Getopt for Command Line Processing in PerlNova Patch
 
10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming language10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming languageYaroslav Tkachenko
 
Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!Workhorse Computing
 
React PHP: the NodeJS challenger
React PHP: the NodeJS challengerReact PHP: the NodeJS challenger
React PHP: the NodeJS challengervanphp
 
The promise of asynchronous php
The promise of asynchronous phpThe promise of asynchronous php
The promise of asynchronous phpWim Godden
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongersbrian d foy
 
ZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 VersionZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 VersionIan Barber
 
Perl web app 테스트전략
Perl web app 테스트전략Perl web app 테스트전략
Perl web app 테스트전략Jeen Lee
 

Mais procurados (20)

Any event intro
Any event introAny event intro
Any event intro
 
Legacy applications - 4Developes konferencja, Piotr Pasich
Legacy applications  - 4Developes konferencja, Piotr PasichLegacy applications  - 4Developes konferencja, Piotr Pasich
Legacy applications - 4Developes konferencja, Piotr Pasich
 
Perl: Coro asynchronous
Perl: Coro asynchronous Perl: Coro asynchronous
Perl: Coro asynchronous
 
AnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
 
Smolder @Silex
Smolder @SilexSmolder @Silex
Smolder @Silex
 
Asynchronous I/O in PHP
Asynchronous I/O in PHPAsynchronous I/O in PHP
Asynchronous I/O in PHP
 
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
Designing Opeation Oriented Web Applications / YAPC::Asia Tokyo 2011
 
Trading with opensource tools, two years later
Trading with opensource tools, two years laterTrading with opensource tools, two years later
Trading with opensource tools, two years later
 
Hacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from PerlHacking Mac OSX Cocoa API from Perl
Hacking Mac OSX Cocoa API from Perl
 
Ethiopian multiplication in Perl6
Ethiopian multiplication in Perl6Ethiopian multiplication in Perl6
Ethiopian multiplication in Perl6
 
Operation Oriented Web Applications / Yokohama pm7
Operation Oriented Web Applications / Yokohama pm7Operation Oriented Web Applications / Yokohama pm7
Operation Oriented Web Applications / Yokohama pm7
 
Modern Getopt for Command Line Processing in Perl
Modern Getopt for Command Line Processing in PerlModern Getopt for Command Line Processing in Perl
Modern Getopt for Command Line Processing in Perl
 
10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming language10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming language
 
Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!Hypers and Gathers and Takes! Oh my!
Hypers and Gathers and Takes! Oh my!
 
React PHP: the NodeJS challenger
React PHP: the NodeJS challengerReact PHP: the NodeJS challenger
React PHP: the NodeJS challenger
 
EC2
EC2EC2
EC2
 
The promise of asynchronous php
The promise of asynchronous phpThe promise of asynchronous php
The promise of asynchronous php
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongers
 
ZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 VersionZeroMQ Is The Answer: DPC 11 Version
ZeroMQ Is The Answer: DPC 11 Version
 
Perl web app 테스트전략
Perl web app 테스트전략Perl web app 테스트전략
Perl web app 테스트전략
 

Semelhante a dotCloud and go

2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Herokuronnywang_tw
 
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Composeraccoony
 
Cutting through the fog of cloud
Cutting through the fog of cloudCutting through the fog of cloud
Cutting through the fog of cloudKyle Rames
 
Reverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemReverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemCyber Security Alliance
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis OverviewLeo Lorieri
 
Drizzle to MySQL, Stress Free Migration
Drizzle to MySQL, Stress Free MigrationDrizzle to MySQL, Stress Free Migration
Drizzle to MySQL, Stress Free MigrationAndrew Hutchings
 
PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22Yuya Takei
 
Best Practices in Handling Performance Issues
Best Practices in Handling Performance IssuesBest Practices in Handling Performance Issues
Best Practices in Handling Performance IssuesOdoo
 
Build your own private openstack cloud
Build your own private openstack cloudBuild your own private openstack cloud
Build your own private openstack cloudNUTC, imac
 
Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)Yuriy Senko
 
Présentation Ikoula au Meet-up Docker à l'école 42
Présentation Ikoula au Meet-up Docker à l'école 42Présentation Ikoula au Meet-up Docker à l'école 42
Présentation Ikoula au Meet-up Docker à l'école 42Ikoula
 
Mise en place d'un client VPN l2tp IPsec sous docker
Mise en place d'un client VPN l2tp IPsec sous dockerMise en place d'un client VPN l2tp IPsec sous docker
Mise en place d'un client VPN l2tp IPsec sous dockerNicolas Trauwaen
 
Openstack 101
Openstack 101Openstack 101
Openstack 101POSSCON
 
Introduction to cloudforecast
Introduction to cloudforecastIntroduction to cloudforecast
Introduction to cloudforecastMasahiro Nagano
 

Semelhante a dotCloud and go (20)

R-House (LSRC)
R-House (LSRC)R-House (LSRC)
R-House (LSRC)
 
Da APK al Golden Ticket
Da APK al Golden TicketDa APK al Golden Ticket
Da APK al Golden Ticket
 
2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku2012 coscup - Build your PHP application on Heroku
2012 coscup - Build your PHP application on Heroku
 
Simple docker hosting in FIWARE Lab
Simple docker hosting in FIWARE LabSimple docker hosting in FIWARE Lab
Simple docker hosting in FIWARE Lab
 
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
파이썬 개발환경 구성하기의 끝판왕 - Docker Compose
 
Cutting through the fog of cloud
Cutting through the fog of cloudCutting through the fog of cloud
Cutting through the fog of cloud
 
Reverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemReverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande Modem
 
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
[EXTENDED] Ceph, Docker, Heroku Slugs, CoreOS and Deis Overview
 
Drizzle to MySQL, Stress Free Migration
Drizzle to MySQL, Stress Free MigrationDrizzle to MySQL, Stress Free Migration
Drizzle to MySQL, Stress Free Migration
 
PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22
 
Ubic
UbicUbic
Ubic
 
Ubic-public
Ubic-publicUbic-public
Ubic-public
 
Best Practices in Handling Performance Issues
Best Practices in Handling Performance IssuesBest Practices in Handling Performance Issues
Best Practices in Handling Performance Issues
 
Intro django
Intro djangoIntro django
Intro django
 
Build your own private openstack cloud
Build your own private openstack cloudBuild your own private openstack cloud
Build your own private openstack cloud
 
Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)Python from zero to hero (Twitter Explorer)
Python from zero to hero (Twitter Explorer)
 
Présentation Ikoula au Meet-up Docker à l'école 42
Présentation Ikoula au Meet-up Docker à l'école 42Présentation Ikoula au Meet-up Docker à l'école 42
Présentation Ikoula au Meet-up Docker à l'école 42
 
Mise en place d'un client VPN l2tp IPsec sous docker
Mise en place d'un client VPN l2tp IPsec sous dockerMise en place d'un client VPN l2tp IPsec sous docker
Mise en place d'un client VPN l2tp IPsec sous docker
 
Openstack 101
Openstack 101Openstack 101
Openstack 101
 
Introduction to cloudforecast
Introduction to cloudforecastIntroduction to cloudforecast
Introduction to cloudforecast
 

Último

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 

Último (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

dotCloud and go

  • 1. dotCloud and go Una Breve Introduzione a DotCloud 1
  • 3. 3
  • 4. 4
  • 5. 5
  • 6. 6
  • 7. 7
  • 8. 8
  • 9. 9
  • 12. QUANTO TEMPO CI METTO? 12
  • 13. dotCloud 13
  • 14. 14
  • 15. IaaS - PaaS - SaaS 15
  • 16. IaaS - PaaS - SaaS 15
  • 17. 16
  • 18. 17
  • 19. 18
  • 20. 19
  • 21. dotcloud 20
  • 23. Easy Install è un modulo python (easy_install) incluso in setuptools che vi consente di scaricare ed installare automaticamente pacchetti Python. 22
  • 24. Easy Install è un modulo python (easy_install) incluso in setuptools che vi consente di scaricare ed installare automaticamente pacchetti Python. 23
  • 26. (è il motivo per cui queste slide sono nere) 25
  • 27. 26 (-:
  • 29. 28 )-:
  • 30. $ dotcloud create whatever Created application "whatever" 29
  • 31. 30
  • 32. $ cat dotcloud.yml www: type: perl approot: www backend: type: perl-worker approot: backend nosqldb: type: redis sqldb: type: mysql 31
  • 33. $ cat dotcloud.yml www: type: perl approot: www backend: type: perl-worker approot: backend nosqldb: type: redis sqldb: type: mysql 32
  • 34. $ cat dotcloud.yml www: type: perl approot: www backend: type: perl-worker approot: backend nosqldb: type: redis sqldb: type: mysql 33
  • 36. $ cat app.psgi #!/usr/bin/env perl use Dancer; use whatever; dance(); 35
  • 37. $ cat Makefile.PL ... PREREQ_PM => { 'Test::More' => 0, 'YAML' => 0, 'Dancer' => 1.3070, 'Plack::Request' => 0, 'Template' => 0, 'JSON' => 0, 'Redis' => 0, ... }, ... 36
  • 39. $ cat supervisord.conf [program:exporter] command = perl /home/dotcloud/current/bin/exporter [program:saver] command = perl /home/dotcloud/current/bin/saver 38
  • 40. $ cat supervisord.conf [program:exporter] command = perl /home/dotcloud/current/bin/exporter [program:saver] command = perl /home/dotcloud/current/bin/saver 39
  • 41. $ cat supervisord.conf [program:exporter] command = perl /home/dotcloud/current/bin/exporter [program:saver] command = perl /home/dotcloud/current/bin/saver 40
  • 42. $ cat dotcloud.yml www: type: perl approot: www backend: type: perl-worker approot: backend nosqldb: type: redis sqldb: type: mysql 41
  • 44. 43
  • 45. $ cat /home/dotcloud/environment.yml DOTCLOUD_ENVIRONMENT: default DOTCLOUD_NOSQLDB_REDIS_HOST: whatever-polettix.dotcloud.com DOTCLOUD_NOSQLDB_REDIS_LOGIN: redis DOTCLOUD_NOSQLDB_REDIS_PASSWORD: ... DOTCLOUD_NOSQLDB_REDIS_PORT: '13749' DOTCLOUD_NOSQLDB_REDIS_URL: ... DOTCLOUD_PROJECT: whatever DOTCLOUD_SERVICE_ID: 0 DOTCLOUD_SERVICE_NAME: www DOTCLOUD_SQLDB_MYSQL_HOST: whatever-polettix.dotcloud.com DOTCLOUD_SQLDB_MYSQL_LOGIN: root DOTCLOUD_SQLDB_MYSQL_PASSWORD: ... DOTCLOUD_SQLDB_MYSQL_PORT: '13747' DOTCLOUD_SQLDB_MYSQL_URL: ... 44
  • 46. use JSON qw< from_json >; use File::Slurp qw< read_file >; sub get_dotcloud_config { my $filename = shift || '/home/dotcloud/environment.json'; my $config_text = read_file($filename); my $config = from_json($config_text); return $config; } ## end sub get_dotcloud_config 45
  • 47. sub get_redis { my $config = get_dotcloud_config(); my ($password, $hostname, $port) = map { $config->{'DOTCLOUD_NOSQLDB_REDIS_' . $_} } qw< PASSWORD HOST PORT >; require Redis; my $redis = Redis->new(server => "$hostname:$port"); $redis->auth($password); return $redis; } 46
  • 48. ROTFL sub get_redis { my $config = get_dotcloud_config(); my ($password, $hostname, $port) = map { $config->{'DOTCLOUD_NOSQLDB_REDIS_' . $_} } qw< PASSWORD HOST PORT >; require Redis; my $redis = Redis->new(server => "$hostname:$port"); $redis->auth($password); return $redis; } 47
  • 50. sub get_dbh { my $config = get_dotcloud_config(); my ($username, $password, $hostname, $port) = map { $config->{'DOTCLOUD_SQLDB_MYSQL_' . $_} } qw< LOGIN PASSWORD HOST PORT >; require DBI; my $dbh = DBI->connect( "dbi:mysql:host=$hostname;port=$port" . ";database=whatever", $username, $password, { RaiseError => 1}, ); return $dbh; } 49
  • 51. 50
  • 52. 51
  • 55. 54
  • 57. $ dotcloud push whatever # Found dotcloud.yml: Using /home/poletti/sviluppo/ perl/whatever as a base directory # upload /home/poletti/sviluppo/perl/whatever ssh:// dotcloud@uploader.dotcloud.com:443/whatever/ branch:master # git ... 2011-08-27 09:00:16 [api] Deploy whatever scheduled for revision=latest 2011-08-27 09:00:16 [api] Waiting for the build. (It may take a few minutes) 2011-08-27 09:00:17 [api] All the services are ready. Beginning the build. ... 56
  • 58. uso git 57
  • 63. $ dotcloud list whatever whatever: - www (type: perl; instances: 1) - nosqldb (type: redis; instances: 1) - sqldb (type: mysql; instances: 1) - backend (type: perl-worker; instances: 1) $ dotcloud url whatever www: http://www.whatever.dotcloud.com/ 62
  • 64. 63
  • 65. $ dotcloud info whatever.backend build_revision: git-b2f52d5 cluster: wolverine config: {} created_at: 1313990084.301964 image_version: b81a3f3949a8 (latest) ports: - name: ssh url: ssh://dotcloud@whatever-polettix.dotcloud.com:13750 state: running type: perl-worker 64
  • 67. type: mysql $ dotcloud info whatever.sqldb cluster: wolverine config: mysql_password: <the-password> created_at: 1313990083.324873 ... $ dotcloud run whatever.sqldb -- mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. ... mysql> CREATE TABLE weight (... 66
  • 69. dotcloud logs (Luke!) 68
  • 70. $ dotcloud logs whatever.backend # tail -F /var/log/supervisor/*.log ==> /var/log/supervisor/exporter-stderr---supervisor-2y6P9O.log <== [2011/08/27 01:35:25 INFO ] serving pending requests if needed... [2011/08/27 01:35:25 INFO ] waiting for more export requests... [2011/08/27 01:39:20 INFO ] serving pending requests if needed... [2011/08/27 01:39:20 INFO ] waiting for more export requests... [2011/08/27 01:39:42 INFO ] got element to export: {"email":"flavio@polettix.it","username":"silvia"} [2011/08/27 01:42:18 INFO ] serving pending requests if needed... [2011/08/27 01:42:18 INFO ] waiting for more export requests... [2011/08/27 01:42:30 INFO ] got element to export: {"email":"flavio@polettix.it","username":"silvia"} [2011/08/27 09:00:24 INFO ] serving pending requests if needed... [2011/08/27 09:00:24 INFO ] waiting for more export requests... ==> /var/log/supervisor/exporter-stdout---supervisor-foI5vi.log <== ==> /var/log/supervisor/saver-stderr---supervisor-pt1_hK.log <== [2011/08/27 01:35:25 INFO ] waiting for more data... [2011/08/27 01:36:04 INFO ] got element to save: {"epoch":1313913600,"weight":83200,"username":"flavio"} [2011/08/27 01:37:25 INFO ] got element to save: {"epoch":1313827200,"weight":62000,"username":"silvia"} [2011/08/27 01:39:20 INFO ] performing initial transfer if needed... [2011/08/27 01:39:20 INFO ] waiting for more data... [2011/08/27 01:42:18 INFO ] performing initial transfer if needed... [2011/08/27 01:42:18 INFO ] waiting for more data... [2011/08/27 01:44:04 INFO ] got element to save: {"epoch":1313913600,"weight":78000,"username":"whatever"} [2011/08/27 09:00:24 INFO ] performing initial transfer if needed... [2011/08/27 09:00:24 INFO ] waiting for more data... ==> /var/log/supervisor/saver-stdout---supervisor-iQDgpA.log <== ==> /var/log/supervisor/supervisord.log <== 2011-08-27 01:42:18,703 INFO spawned: 'saver' with pid 19587 2011-08-27 01:42:18,713 INFO spawned: 'exporter' with pid 19588 2011-08-27 01:42:19,914 INFO success: saver entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) 2011-08-27 01:42:19,943 INFO success: exporter entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) 2011-08-27 09:00:22,067 INFO stopped: saver (terminated by SIGTERM) 2011-08-27 09:00:22,070 INFO stopped: exporter (terminated by SIGTERM) 2011-08-27 09:00:24,079 INFO spawned: 'saver' with pid 19729 2011-08-27 09:00:24,086 INFO spawned: 'exporter' with pid 19730 2011-08-27 09:00:25,426 INFO success: saver entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) 2011-08-27 09:00:25,426 INFO success: exporter entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) 69
  • 72. dotcloud run (like hell) 71
  • 73. $ dotcloud run whatever.www -- ps afx # ps afx PID TTY STAT TIME COMMAND 3558 ? S 0:00 sshd: dotcloud@pts/0 3559 pts/0 Rs+ 0:00 _ ps afx 144 ? Ss 0:44 /usr/bin/python /usr/ 3495 ? S 0:00 _ /usr/local/bin/uwsg 3496 ? S 0:00 _ /usr/local/bin/ 72
  • 76. dotcloud ssh (no root, sorry!) 75
  • 77. $ dotcloud ssh whatever.backend # $SHELL dotcloud@whatever-default-backend-0:~$ $ dotcloud ssh whatever.nosqldb # $SHELL redis@whatever-default-nosqldb-0:~$ redis-cli redis> auth ... OK redis> smembers users 1) "silvia" 2) "flavio" 3) "whatever" 76
  • 78. 77
  • 81. $ dotcloud push --all whatever 80
  • 82. $ dotcloud push whatever -b branch 81
  • 83. 82
  • 84. 83
  • 85. È tutto molto triste 84
  • 86. 85
  • 88. 87

Notas do Editor

  1. \n
  2. &amp;#xC8; utile riferire il contenuto della presentazione ad un esempio di massima... ed in questo caso mi riguarda da vicino!\n
  3. Sicuramente non ve ne sarete accorti, ma sono un tantino sovrappeso. L&amp;#x2019;idea &amp;#xE8; quella di un sistema per la registrazione giornaliera del mio peso... quantomeno per vergognarmi a dovere!\n
  4. Il sistema &amp;#xE8; costituito da quattro blocchi funzionali separati: un front-end per l&amp;#x2019;interazione con gli utenti, un database &amp;#x201C;no SQL&amp;#x201D; per memorizzare i dati dell&amp;#x2019;ultimo mese, un back-end per le operazioni dietro le quinte ed un database SQL per registrare i dati da qui all&amp;#x2019;eternit&amp;#xE0;. Certo, un&amp;#x2019;architettura un po&amp;#x2019; roboante per registrare una sola misurazione al giorno, ma diciamo che vista la stazza il sistema si potrebbe appesantire rapidamente.\n
  5. L&amp;#x2019;interazione dell&amp;#x2019;utente &amp;#xE8; con il Front-End attraverso l&amp;#x2019;utilizzo di un comune browser; il Front-End interagisce a sua volta con il database &amp;#x201C;no SQL&amp;#x201D; (redis in particolare) per sia per visualizzare i dati relativi all&amp;#x2019;ultimo mese che per registrarne di nuovi. In particolare, si pu&amp;#xF2;: visualizzare i dati mensili di ciascun utente, inserire una nuova misura oppure richiedere l&amp;#x2019;export dei dati storici relativi ad un utente (questo export verr&amp;#xE0; spedito via email a cura del Back-End).\n
  6. Redis implementa un meccanismo Sottoscrizione/Pubblicazione molto comodo per gestire delle code; il Back-End &amp;#xE8; impostato per ascoltare le notifiche tanto in relazione all&amp;#x2019;inserimento/aggiornamento dei dati di peso di un giorno (per salvarli nel database completo) quanto per ricevere le richieste di export dei dati. In entrambi i casi viene utilizzata una lista per trasferire i dati secondo una gestione a coda, ed il meccanismo di notifica per evitare che il Back-End faccia richieste continue per vedere se ci sono nuovi dati.\n
  7. Come conseguenza dell&amp;#x2019;inserimento/aggiornamento di uno o pi&amp;#xF9; dati di peso, il Back-End consuma la coda relativa ai &amp;#x201C;new-weights&amp;#x201D; provvedendo all&amp;#x2019;inserimento nel database MySQL. Una volta terminato si rimette in ascolto aspettando la notifica successiva.\n
  8. Analogamente, il Back-End consuma anche la coda di richieste di export dei dati, provvedendo a raccogliere i dati dal database per l&amp;#x2019;utente richiesto, formattarli come file CSV e spedirli via email all&amp;#x2019;indirizzo passato dal Front-End nella richiesta di export.\n
  9. I quattro elementi base dell&amp;#x2019;architettura sono stati implementati con tecnologie differenti: Perl/Dancer per il Front-End e Perl &amp;#x201C;semplice&amp;#x201D; per il Back-End, oltre ovviamente ai due database basati su Redis e MySQL.\n
  10. Il problema ora &amp;#xE8; che questo marchingegno dovrebbe essere messo da qualche parte a cui posso accedere facilmente ovunque mi trovi...\n
  11. ... il che poi non &amp;#xE8; l&amp;#x2019;unico problema, perch&amp;#xE9; dovr&amp;#xF2; anche capire come far&amp;#xF2; a mettere tutti questi elementi differenti...\n
  12. ... per non parlare del fatto che tutto questo processo mi richieder&amp;#xE0; plausibilmente una bella fetta di tempo.\n
  13. E qui, finalmente, dopo solo 13 slide... arriviamo a dotCloud.\n
  14. La homepage &amp;#xE8; piuttosto invitante: sono disponibili tante combinazioni in &amp;#x201C;stack&amp;#x201D; applicativi differenti in una piattaforma di controllo e gestione unica, il che sembra l&amp;#x2019;ideale per ospitare la nostra applicazione che &amp;#xE8; basata su quattro elementi differenti fra loro. Fortunatamente - altrimenti questa presentazione avrebbe avuto seri problemi - questi quattro elementi che abbiamo scelto sono tutti supportati.\n
  15. Di cloud c&amp;#x2019;&amp;#xE8; molto da parlare, soprattutto perch&amp;#xE9; dopo il calcio sembra un argomento in cui ognuno ha una sua idea. All&amp;#x2019;interno della tassonomia pi&amp;#xF9; classica - l&amp;#x2019;Infrastruttura come Servizio, la Piattaforma come Servizio, il Software come Servizio - dotCloud si colloca decisamente come un un fornitore di Piattaforma, ossia strizza l&amp;#x2019;occhio allo sviluppatore dandogli un ambiente che NON deve gestire a pi&amp;#xF9; basso livello (come sarebbe successo con IaaS, ad esempio Amazon EC2 o Rackspace Servers) ma che gli consente di implementare la propria applicazione, non di utilizzarne una gi&amp;#xE0; costruita (come avviene tipicamente con SaaS).\n
  16. Di cloud c&amp;#x2019;&amp;#xE8; molto da parlare, soprattutto perch&amp;#xE9; dopo il calcio sembra un argomento in cui ognuno ha una sua idea. All&amp;#x2019;interno della tassonomia pi&amp;#xF9; classica - l&amp;#x2019;Infrastruttura come Servizio, la Piattaforma come Servizio, il Software come Servizio - dotCloud si colloca decisamente come un un fornitore di Piattaforma, ossia strizza l&amp;#x2019;occhio allo sviluppatore dandogli un ambiente che NON deve gestire a pi&amp;#xF9; basso livello (come sarebbe successo con IaaS, ad esempio Amazon EC2 o Rackspace Servers) ma che gli consente di implementare la propria applicazione, non di utilizzarne una gi&amp;#xE0; costruita (come avviene tipicamente con SaaS).\n
  17. Non rimane che iscriversi, tanto &amp;#xE8; gratuito...\n
  18. ... anche se dovrete riempire un po&amp;#x2019; di scartoffie digitali.\n
  19. Se avete un account, potete entrare e trovare la roboante &amp;#x201C;dashboard&amp;#x201D; di ingresso...\n
  20. ... ossia una pagina piuttosto anonima che vi invita ad installare il programma di controllo a linea di comando. Questa pagina dovr&amp;#xE0; cambiare, spero non sia avvenuto prima di questo talk!\n
  21. Lo strumento principale di interazione con dotCloud &amp;#xE8; - secondo il principio della minima sorpresa - un programma che si chiama dotcloud.\n
  22. Installarlo dovrebbe essere piuttosto semplice, visto che il modo consigliato per farlo &amp;#xE8; utilizzare un altro programma chiamato &amp;#x201C;easy_install&amp;#x201D;. Diciamo che quanto a marketing siamo sulla strada giusta... ma il marketing non basta.\n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. Non ostante easy_install sia supportato anche da versioni precedenti di Python, per utilizzare dotcloud (il programma) &amp;#xE8; necessario avere Python 2.7 almeno, ma non Python 3.\n
  29. Questo pu&amp;#xF2; essere un problema per parecchi, perch&amp;#xE9; se siete dei nostalgici come me starete utilizzando una distribuzione che probabilmente ancora non include questa versione di Python. A me &amp;#xE8; toccato installarlo a mano. Dunque easy_install &amp;#xE8; un ottimo gestore... il problema &amp;#xE8; tutto quello su cui poggia! Sarebbe stato bello avere pythonbrew... o quantomeno sapere se c&amp;#x2019;erano alternative.\n
  30. Siamo pronti per creare la nostra prima applicazione. Il principio della minima sorpresa continua a spadroneggiare, perch&amp;#xE9; basta lanciare il sottocomando &amp;#x201C;create&amp;#x201D; dando il nome della nostra applicazione.\n
  31. L&amp;#x2019;applicazione, in particolare, &amp;#xE8; stata organizzata in una struttura come quella in figura: il Front-End ha una sua directory &amp;#x201C;www&amp;#x201D;, il Back-End una sua &amp;#x201C;backend&amp;#x201D;. Oltre a queste due cartelle si nota la presenza di un file di configurazione YAML il cui nome lascia sospettare la sua destinazione.\n
  32. Il file &amp;#xE8; in effetti quanto verr&amp;#xE0; utilizzato per costruire il nostro stack applicativo.\n
  33. In particolare possiamo riconoscere, a livello pi&amp;#xF9; elevato, i differenti servizi necessari per realizzare la nostra applicazione. Per ciascun servizio viene specificato il &amp;#x201C;type&amp;#x201D;, ossia &amp;#x201C;perl&amp;#x201D; per applicazioni di Front-End web, &amp;#x201C;perl-worker&amp;#x201D; per applicazioni di Back-End in Perl, redis e mysql per i due tipi di database.\n
  34. Nel file specifichiamo anche che le directory di base per Front-End e Back-End sono separate, in modo che possiamo avere una struttura pulita. DotCloud sapr&amp;#xE0; quindi che nelle macchine dove verr&amp;#xE0; realizzato il Front-End la directory di riferimento sar&amp;#xE0; &amp;#x201C;www&amp;#x201D;, mentre in quelle del Back-End sar&amp;#xE0; &amp;#x201C;backend&amp;#x201D;.\n
  35. Il tipo di servizio &amp;#x201C;perl&amp;#x201D; &amp;#xE8; orientato alla realizzazione di Front-End di tipo web basati, per l&amp;#x2019;appunto, su Perl. Il modello di riferimento in questo caso &amp;#xE8; quello dell&amp;#x2019;interfaccia PSGI, che costituisce un porting piuttosto felice nel mondo Perl di idee nate in ambito Ruby/Python. Non ostante la directory abbia vari elementi, quelli realmente interessanti per dotCloud sono due: app.psgi e Makefile.PL.\n
  36. app.psgi, in particolare, &amp;#xE8; l&amp;#x2019;applicazione web vera e propria. Deve SEMPRE esistere in un servizio dotCloud di tipo &amp;#x201C;perl&amp;#x201D;. Nel caso specifico si &amp;#xE8; utilizzato il framework Dancer, molto comodo e costruito in modo da rispettare l&amp;#x2019;interfaccia PSGI. Come si potr&amp;#xE0; intuire, la vera &amp;#x201C;ciccia&amp;#x201D; dell&amp;#x2019;applicazione si trova all&amp;#x2019;interno del modulo &amp;#x201C;whatever&amp;#x201D;, che - l&amp;#x2019;avrete gi&amp;#xE0; indovinato - &amp;#xE8; nella directory lib. In realt&amp;#xE0; qui per&amp;#xF2; pu&amp;#xF2; esserci qualunque cosa che possa essere considerata aderente alle specifice PSGI.\n
  37. L&amp;#x2019;altro file molto importante - per quanto tecnicamente non obbligatorio - &amp;#xE8; Makefile.PL. Va generato in maniera analoga a quanto si farebbe per una distribuzione su CPAN; come in quel caso, quindi, &amp;#xE8; utile perch&amp;#xE9; contiene una sezione PREREQ_PM dove possiamo andare ad inserire tutti i prerequisiti della nostra applicazione web.\n
  38. La tipologia di servizio &amp;#x201C;perl-worker&amp;#x201D; &amp;#xE8; anch&amp;#x2019;essa basata su Perl, ma &amp;#xE8; orientata all&amp;#x2019;esecuzione di programmi di lunga durata (demoni). Anche in questo caso il file Makefile.PL pu&amp;#xF2;/deve essere utilizzato per specificare i requisiti in termini di moduli da installare, altrimenti il perl che avremo a disposizione non ci permetter&amp;#xE0; di lavorare.\n
  39. Il file pi&amp;#xF9; peculiare in questo caso &amp;#xE8; per&amp;#xF2; supervisord.conf, che non &amp;#xE8; altro che il file di configurazione del progamma supervisord. Tramite questo file possiamo specificare quanti programmi devono essere eseguiti contemporanemente e monitorati per controllare che vengano tenuti in esecuzione. Ovviamente potrete soddisfare ogni vostra curiosit&amp;#xE0; su http://supervisord.org/; nel caso in questione, basta notare che per ciascun demone c&amp;#x2019;&amp;#xE8; un titolo con il nome da dare ed una riga &amp;#x201C;command&amp;#x201D; dove specifichiamo cosa va eseguito.\n
  40. Avrete sicuramente fatto caso che nella specifica dei comandi compaiono dei percorsi piuttosto curiosi. Ebbene s&amp;#xEC;, poich&amp;#xE9; questi programmi verranno eseguiti su delle macchine... queste macchine hanno un filesystem ed i vostri programmi del Back-End li troverete proprio l&amp;#xEC;!\n
  41. In particolare, quando la vostra applicazione viene distribuita, all&amp;#x2019;interno della macchina del Back-End (nel Front-End &amp;#xE8; analogo) viene creata una directory con la directory base che ha un nome non anticipabile. Il sistema di dotCloud, per&amp;#xF2;, vi garantisce che verr&amp;#xE0; anche creato un link simbolico che da /home/dotcloud/current punta verso la directory principale del servizio.\n
  42. In poche parole, /home/dotcloud/current non fa altro che puntare a quella sottodirectory che abbiamo specificato come &amp;#x201C;approot&amp;#x201D; nel file di configurazione dotcloud.yml.\n
  43. Abbiamo capito cosa succede a Front-End e Back-End... ma per i database che succede? In realt&amp;#xE0; vengono create delle macchine virtuali &amp;#x201C;speciali&amp;#x201D; anche in quel caso - la specialit&amp;#xE0; risiede nel fatto che le macchine di tipo &amp;#x201C;redis&amp;#x201D; contengono il server ed il client Redis e quelle di tipo MySQL... lo avrete gi&amp;#xE0; indovinato.\nIl problema per&amp;#xF2; &amp;#xE8;: come ci si connette a questi due database? Dove stanno, soprattutto?\n
  44. Per rispondere a queste domande dobbiamo tornare alla struttura delle directory che ci troviamo nelle macchine del Front-End e del Back-End. Abbiamo gi&amp;#xE0; detto che /home/dotcloud/current punta alla directory specificata come approot per ciascuna applicazione, ma nella directory /home/dotcloud ci sono altri due file interessanti: environment.yml (in formato YAML) ed environment.json (in formato JSON).\n
  45. Molto prosaicamente, questi due file contengono entrambi le informazioni necessarie per raggiungere i servizi dati del nostro stack, includendo cio&amp;#xE8; gli indirizzi di dove si trovano, su quale porta sono in ascolto e quali sono le credenziali di accesso.\n
  46. A questo punto, a seconda che ci piaccia di pi&amp;#xF9; JSON o YAML, &amp;#xE8; facile scrivere una routine che va a leggere il file di configurazione giusto per caricare le differenti variabili che ci servono per la connessione.\n
  47. Per Redis avremo bisogno della password e dei dettagli sulla connessione, ossia il nome della macchina su cui &amp;#xE8; ospitato il nostro servizio e la porta. Nel restituire un oggetto Redis facciamo anche un favore all&amp;#x2019;utente e &amp;#x201C;sblocchiamo&amp;#x201D; la connessione inviando la password.\n
  48. Incidentalmente, &amp;#x201C;get_redis&amp;#x201D; fa ridere. Beh, almeno MI fa ridere.\n
  49. \n
  50. Per la connessione MySQL il discorso &amp;#xE8; analogo: basta andare a prendere le variabili giuste dalla configurazione caricata e creare l&amp;#x2019;oggetto utilizzando il modulo DBI. Il resto &amp;#xE8; roba standard.\n
  51. Questo codice &amp;#xE8; in realt&amp;#xE0; utile tanto al Front-End quanto al Back-End... dove collocarlo? Occorre duplicare?\n
  52. L&amp;#x2019;aspetto interessante &amp;#xE8; che sia l&amp;#x2019;istanza di Front-End che quella di Back-End contengono in realt&amp;#xE0; tutto il codice, ossia anche quello dell&amp;#x2019;altra istanza. Analogamente a quanto succede con /home/dotcloud/current (che punta alla appdir impostata nel file dotcloud.yml), l&amp;#x2019;infrastruttura di dotCloud crea anche un link simbolico che da /home/dotcloud/code punta alla directory principale della distribuzione.\n
  53. Con questi presupposti, dunque, la soluzione pi&amp;#xF9; semplice &amp;#xE8; quella di aggiungere un&amp;#x2019;area comune a cui i vari servizi possono attingere.\n
  54. Nel caso specifico, per&amp;#xF2;, c&amp;#x2019;&amp;#xE8; un modulo su CPAN che serve proprio a questo scopo...\n
  55. ... ma non ne parleremo oltre, visto che si tratta di autopromozione!\n
  56. \n
  57. Per andare in produzione &amp;#xE8; sufficiente &amp;#x201C;spingere&amp;#x201D; la nostra applicazione su dotcloud. La prima volta verranno normalmente inizializzati gli ambienti caricando i vari moduli impostati nei prerequisiti, quindi ci metter&amp;#xE0; un po&amp;#x2019; di tempo; successivamente dovrebbe essere pi&amp;#xF9; rapido, a meno di non aggiungere svariati altri prerequisiti.\n
  58. Nel caso dell&amp;#x2019;esempio io utilizzo git, per cui dotcloud &amp;#x201C;sa cosa fare&amp;#x201D; e prende i file da git. Questo &amp;#xE8; un punto su cui occorre fare attenzione, perch&amp;#xE9; per default va a prendere il ramo &amp;#x201C;master&amp;#x201D; e non &amp;#xE8; detto che sia quello su cui state lavorando o che sia quello che volete effettivamente attivare su dotCloud.\n
  59. Se utilizzate mercurial il comportamento &amp;#xE8; analogo.\n
  60. In alternativa potete non utilizzare nessuno dei due, nel qual caso il meccanismo di invio scelto da dotcloud sar&amp;#xE0; rsync.\n
  61. \n
  62. Nel tempo di questa breve digressione il caricamento dell&amp;#x2019;applicazione dovrebbe essere terminato.\n
  63. Il programma dotcloud mette a disposizione vari comandi; in questa fase, &amp;#xE8; utile vedere cosa sia stato effettivamente creato per la nostra applicazione - ossia il nostro &amp;#x201C;stack&amp;#x201D; - e dove sia possibile raggiungerla con il browser.\nIl comando list, nell&amp;#x2019;esempio, riporta una cosa interessante: per ciascun servizio &amp;#xE8; stata attiva un&amp;#x2019;istanza. Queste istanze altro non sono che macchine virtuali attivate nella nuvola di Amazon EC2.\n
  64. Certo, la grafica lascia a desiderare... ma ad occhio e croce il Front-End funziona visto che riporta anche un elenco degli utenti presenti ed un paio di registrazioni.\n
  65. Il comando &amp;#x201C;info&amp;#x201D; &amp;#xE8; molto utile per avere informazioni generali sui vari servizi. Avrete notato che il nome dei servizi &amp;#xE8; composto dal nome dell&amp;#x2019;applicazione, un punto e poi il nome del servizio vero e proprio all&amp;#x2019;interno dell&amp;#x2019;applicazione. In questo modo potete avere dei servizi &amp;#x201C;backend&amp;#x201D; in tutte le applicazioni, senza che questi si disturbino fra loro.\n
  66. \n
  67. Il comando run torna immediatamente utile perch&amp;#xE9; c&amp;#x2019;&amp;#xE8; un&amp;#x2019;ultima cosa che &amp;#xE8; stata lasciata in sospeso nelle basi dati. Con Redis non c&amp;#x2019;&amp;#xE8; bisogno di inizializzazione perch&amp;#xE9; sostanzialmente &amp;#x201C;autovivifica&amp;#x201D;, ma con MySQL occorre definire una tabella, altrimenti &amp;#xE8; difficile scriverci qualcosa.\nUtilizzando il comando info possiamo vedere la password - analogamente potremmo entrare nel Front-End o nel Back-End e leggerla dentro il file environment.*, ma a che pro se esiste un comando apposito?\nCon il comando run possiamo invece lanciare qualsiasi comando remoto; in questo caso, dunque, lanciamo il client di mysql per poter definire la tabella dove il Back-End salva i dati. Certo, certo: alla creazione della tabella potrebbe provvedere il Back-End stesso, ma poi come mostravo il comando run?\n
  68. Ovviamente nessuno di noi pensa che andr&amp;#xE0; liscia al primo tentativo. Nemmeno nei 100 successivi, per la verit&amp;#xE0;.\n
  69. Il primo santo a cui votarsi &amp;#xE8; il comando logs, che ci consente di vedere i log specifici di ciascun servizio.\n
  70. Nel Back-End, ad esempio, d&amp;#xE0; una visione contemporanea di tutti i file nella directory /var/log/supervisor/, ossia dei log dei nostri programmi pi&amp;#xF9; il log del supervisord stesso. Potete decidere di salvare i log da qualche altra parte, ma &amp;#xE8; particolarmente comodo utilizzare STDERR e lasciare che vengano messi in un posto dove possono essere raccolti facilmente con il comando logs.\n
  71. Che fare se i log non bastano? A parte la consueta chiodata, ovviamente?\n
  72. Beh, il comando run pu&amp;#xF2; tornare utile anche in questa occasione.\n
  73. In particolare, tramite run possiamo eseguire comandi nell&amp;#x2019;istanza remota, quindi &amp;#xE8; un po&amp;#x2019; come avere una shell a disposizione. Magari un po&amp;#x2019; lenta, visto che si dove riconnettere ad ogni comando.\n
  74. Che fare quindi se vogliamo andare oltre?!?\n
  75. Beh, non rimane che entrare da terminale sull&amp;#x2019;istanza che ospita il servizio che fa le bizze.\n
  76. No, l&amp;#x2019;accesso come root non &amp;#xE8; contemplato.\n
  77. A seconda dell&amp;#x2019;istanza troveremo ovviamente un ambiente differente con programmi differenti a disposizione. Ad esempio, redis-cli &amp;#xE8; disponibile nell&amp;#x2019;istanza di tipo &amp;#x201C;redis&amp;#x201D; ma non nell&amp;#x2019;istanza del backend - anche se avrebbe fatto comodo.\n
  78. Trovo che Pitfall! fosse un gioco stupendo, ma occorre stare attenti a non cadere!\n
  79. Una delle noie maggiori che ho trovato &amp;#xE8; il fatto che occorre sempre fare &amp;#x201C;git commit&amp;#x201D; prima di effettuare il push, altrimenti dotcloud non prende le modifiche nella directory di lavoro. Stiamo ovviamente parlando del caso in cui venga utilizzato git.\n
  80. \n
  81. Un&amp;#x2019;alternativa molto rapida e molto comoda quando si stanno facendo prove &amp;#xE8; utilizzare &amp;#x201C;--all&amp;#x201D;. In questo modo viene ignorato il meccanismo di base della distribuzione e viene sempre utilizzato rsync.\n
  82. L&amp;#x2019;altro aspetto a cui prestare attenzione &amp;#xE8; che il push normalmente prende il ramo &amp;#x201C;master&amp;#x201D;, per cui se si lavora ad un altro ramo occorre ricordarsi di includere il nome del ramo giusto. Questa la trovo una mancanza, poich&amp;#xE9; &amp;#xE8; semplice sapere quale sia il ramo attivo di una directory di lavoro; probabilmente per&amp;#xF2; per chi ci lavora &amp;#x201C;sul serio&amp;#x201D; &amp;#xE8; un meccanismo di protezione, per cui non borbotter&amp;#xF2; oltre.\n
  83. Dopo averci dato tanta libert&amp;#xE0;... purtroppo dotCloud ha posto anche delle restrizioni.\n
  84. Da poco tempo &amp;#xE8; infatti uscito il prezziario. &amp;#xC8; proprio vero che una volta si stava meglio: se si entrava nella beta, infatti, si poteva giocare molto. Ora sembra che il piano gratuito consenta di avere al massimo due servizi... che fine far&amp;#xE0; il mio carrozzone che ne ha quattro?\n
  85. \n
  86. Certo, si pu&amp;#xF2; sempre barare...\n
  87. ... ad esempio creando account multipli ed utilizzando un servizio di directory centralizzato dove vengono salvate le configurazioni di tutte le applicazioni (i file &amp;#x201C;environment.*&amp;#x201D; per intenderci). Un esempio di una directory di questo tipo &amp;#xE8; nel link nella slide e - senza nemmeno dirlo - l&amp;#x2019;applicazione &amp;#xE8; fatta per girare su dotcloud utilizzando due servizi.\n
  88. \n