SlideShare a Scribd company logo
1 of 44
Friends, this is clean-up time and we're
            discounting all our silent, electric Ubiks
               by this much money. Yes' we're throwing
           away the bluebook. And remember: every Ubik
            on our lot has been used only as directed.


                              Phillip K. Dick. “Ubik”.




        Ubic
Polymorphic service manager
  github.com/berekuk/ubic
1-minute intro
Install

                     Debian/Ubuntu:
apt-add-repository ppa:berekuk/ubic && apt-get install ubic

                        FreeBSD:
      cd /usr/ports/sysutils/p5-Ubic && make install

                   Everywhere else:
            cpanm Ubic && ubic-admin setup
Write service config

  # cat >/etc/ubic/service/foo

  use Ubic::Service::SimpleDaemon;

  Ubic::Service::SimpleDaemon->new(
      bin => ‘sleep 1000’,
      stdout => ‘/var/log/foo.log’,
  );
Run it


# ubic start foo
Starting foo... started (pid 28152)
Flexible perl-based
 service manager
Flexible perl-based
   polymorphic
 service manager
APIs everywhere
I’ll talk about APIs
instead of features today

• Ubic.pm glue code
• services
• multiservices
• service loaders
Ubic.pm API
Ubic.pm API

Ubic->start(‘foo’);

Ubic->stop(‘foo’);

# and many other methods
Service state is different from
service status

# ubic status foo

foo    running (pid 29551)

# kill 29551

# ubic status foo

foo    not running

# ubic stop foo

Stopping foo... not running

# ubic status

foo    off
Watchdog adjusts service status
in accordance with service state.

# ubic status foo

foo    running (pid 29551)

# kill 29551

# ubic status foo

foo    not running

# ubic-watchdog foo

[Fri Dec 9 03:45:37 2011]	 foo status is 'not running',
restarting
Ubic is not a supervisor



There is no global supervisor process.
Ubic is more similar to init scripts than
to upstart or launchd in this aspect.
Service state is persistent


• state is stored on disk and kept even after
  reboot

• you don’t have to stop services on host
  shutdown and start them on reboot
  (I know some people want a proper
  shutdown; I’ll get to that later)
Ubic.pm API
            consumers

• /usr/bin/ubic — command-line frontend
• ubic.watchdog service — monitors everything
• ubic.ping — reports service status via http
Ideas for more features


• ubic-web — html app frontend
• ‘ubic shutdown’ command which stops
  everything but don’t change state
• parameterized commands
Services API
Service is an object
Services conform to simple API:

 use parent qw(Ubic::Service);

 sub start { ... }

 sub stop { ... }

 sub status { ... }
Start code
can get complicated
 use parent qw(Ubic::Service);

 sub start {
     # check if daemon is running
     # start daemon
     # sleep for some time
     # check status
     # sleep more
     # check status
     # ... etc
 }
So Ubic::Service::Skeleton
   provides shortcuts

  use parent qw(Ubic::Service::Skeleton);

  sub start_impl { ... }
  sub start_impl { ... }
  sub status_impl { ... }

  sub timeout_options
      { start => { step => 0.1, trials => 3 } }
  }
Services inherit from
      other services
                               Ubic::Service


Ubic::Multiservice     Ubic::Service::Skeleton


 Ubic::Service::SimpleDaemon                   Ubic::Service::InitScriptWrapper


                       Ubic::Service::ZooKeeper        Ubic::Service::MongoDB

                       Ubic::Service::Plack          Ubic::Service::Memcached



                       Ubic::Service::Starman
Custom status() methods
           Example from Ubic::Service::MongoDB

sub status_impl {

    my $self = shift;

    my $running = check_daemon($self->pidfile);

    return result('not running') unless $running; 

    my $status = MongoDB::Connection->new(...)->admin->run_command({ serverStatus => 1 });

    if (!$status->{ok} || $status->{ok} != 1) {

        return result('broken');

    } else {

        return result('running');

    }

}
SimpleDaemon is the
most popular service class
   Ubic::Service::SimpleDaemon->new(

        bin => ‘plackup /usr/share/foo/app.psgi’,

        stdout => ‘/var/log/foo.log’,

        stderr => ‘/var/log/foo.err.log’,

        ubic_log => ‘/var/log/foo.ubic.log’,

        user => ‘daemon’,

        group => ‘daemon’,

        cwd => ‘/’,

        env => { PERL5LIB => ‘/usr/share/foo/lib’ },

   };
Ideas for
    new service modules
• restart (report ‘broken’ status) on
  memory leaks
• or on code changes
• or once per N seconds
• or if service doesn’t answer http ping
  (parameterize with url, port and
  timeout)
More ideas for
   new service modules
• better mechanism for adding features
  (decorators/roles/middlewares)
• simple daemonizer which uses
  Proc::Daemon instead of Ubic::Daemon
• wrappers for other service managers
  (turn daemontools service to ubic
  service)
Multiservices API
All services belong to
the global service tree

# ubic status
foo     running (pid 1234)
bar     running (pid 1235)
ubic
     ubic.ping      running (pid 2182)
     ubic.update    running (pid 2181)
     ubic.watchdog running (pid 1996)
Files in service dir describe
   services with perl code

   # cat /etc/ubic/service/foo

   use Ubic::Service::SimpleDaemon;

   Ubic::Service::SimpleDaemon->new(
       bin => ‘sleep 1000’,
       stdout => ‘/var/log/foo.log’,
   );
Subdirectories
become multiservices
  # ls ~/ubic/service/ubic/
  ping     update   watchdog

  # ubic status ubic
  ubic
       ubic.ping     running (pid 2182)
       ubic.update   running (pid 2181)
       ubic.watchdog running (pid 1996)
Or you can implement
 multiservice in perl
 # cat /etc/ubic/service/psgi
 use parent qw(Ubic::Multiservice);
 use Ubic::Service::Plack;

 sub simple_service {
     my ($self, $name) = @_;
     return Ubic::Service::Plack->new(...);
 }

 sub service_names {
 my @configs = glob “/psgi_apps/*.psgi”;
     s{^/psgi_apps(.*).psgi$}{$1} for @configs;
     return @configs;
 }
Another use case:
create N services
use Ubic::Multiservice::Simple;
use Ubic::Service::SimpleDaemon;

return Ubic::Multiservice::Simple->new({
    map {
        "worker$_" =>
Ubic::Service::SimpleDaemon->new({
            bin => "/usr/bin/worker.pl",
        })
    } (1..10)
});
Ideas for more
          multiservices

• bind the whole /etc/init.d/ or /service/
  to ubic
• “stash” multiservice — create services
  from command-line without creating
  any configs
Service loaders
Configs with .ini
extension are different

  # cat /etc/ubic/service/foo.ini
  module = Ubic::Service::SimpleDaemon
  [options]
  bin = sleep 1000
  stdout = /var/log/foo.log
Configs with any
extension are different

• ini configs are loaded with
  Ubic::ServiceLoader::Ext::ini
• experimental yaml service loader is in
  separate repo (not sure if extra
  dependency is worth it)
Now we can reach to
  non-perl users
• Node.JS guys at Yandex use Ubic
• Java guys at Yandex use Ubic
• admins who don’t know Perl use Ubic
• all of them do it because they like it, not
  because I forced them :)
• tell your non-perl friends about Ubic
  today!
Ideas for more
        service loaders
• .bin — turn symlink to binary into
  service
• new [addons] section to ini config,
  which would wrap service object in
  listed decorators
• .xml, .json (I know we don’t need so
  many of different formats, but Node.JS
  people like to reinvent the wheel)
More ideas
There are no
cross-platform service managers


 • Let’s port Ubic to Windows!

 • several guys tried to help but disappeared

 • github.com/berekuk/Ubic/wiki/Windows
   is the current plan
Plugins

• add a new command to /usr/bin/ubic

• or add memory leaks monitoring to all
  services at once

• API: apply the given middleware to all
  services
The End
Questions? Patches?

github.com/berekuk/Ubic

#ubic at irc.perl.org

“Like” Ubic on metacpan: metacpan.org/release/Ubic
This is the slide #42

More Related Content

What's hot

Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestrationbcoca
 
Introction to docker swarm
Introction to docker swarmIntroction to docker swarm
Introction to docker swarmHsi-Kai Wang
 
Docker swarm introduction
Docker swarm introductionDocker swarm introduction
Docker swarm introductionEvan Lin
 
Consuming Cinder from Docker
Consuming Cinder from DockerConsuming Cinder from Docker
Consuming Cinder from DockerJohn Griffith
 
Consul and docker swarm cluster
Consul and docker swarm clusterConsul and docker swarm cluster
Consul and docker swarm clusterEueung Mulyana
 
Octo talk : docker multi-host networking
Octo talk : docker multi-host networking Octo talk : docker multi-host networking
Octo talk : docker multi-host networking Hervé Leclerc
 
The age of orchestration: from Docker basics to cluster management
The age of orchestration: from Docker basics to cluster managementThe age of orchestration: from Docker basics to cluster management
The age of orchestration: from Docker basics to cluster managementNicola Paolucci
 
Swarm - A Docker Clustering System
Swarm - A Docker Clustering SystemSwarm - A Docker Clustering System
Swarm - A Docker Clustering Systemsnrism
 
Docker Swarm Introduction
Docker Swarm IntroductionDocker Swarm Introduction
Docker Swarm Introductionrajdeep
 
Introduction to docker swarm
Introduction to docker swarmIntroduction to docker swarm
Introduction to docker swarmWalid Ashraf
 
Wanting distributed volumes - Experiences with ceph-docker
Wanting distributed volumes - Experiences with ceph-dockerWanting distributed volumes - Experiences with ceph-docker
Wanting distributed volumes - Experiences with ceph-dockerEwout Prangsma
 
Nebulaworks Docker Overview 09-22-2015
Nebulaworks Docker Overview 09-22-2015Nebulaworks Docker Overview 09-22-2015
Nebulaworks Docker Overview 09-22-2015Chris Ciborowski
 
Docker Networking & Swarm Mode Introduction
Docker Networking & Swarm Mode IntroductionDocker Networking & Swarm Mode Introduction
Docker Networking & Swarm Mode IntroductionPhi Huynh
 
Couch to OpenStack: Cinder - August 6, 2013
Couch to OpenStack: Cinder - August 6, 2013Couch to OpenStack: Cinder - August 6, 2013
Couch to OpenStack: Cinder - August 6, 2013Trevor Roberts Jr.
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to AnsibleKnoldus Inc.
 

What's hot (20)

Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestration
 
Vagrant
Vagrant Vagrant
Vagrant
 
Introction to docker swarm
Introction to docker swarmIntroction to docker swarm
Introction to docker swarm
 
Introduction to Vagrant
Introduction to VagrantIntroduction to Vagrant
Introduction to Vagrant
 
Docker swarm introduction
Docker swarm introductionDocker swarm introduction
Docker swarm introduction
 
Consuming Cinder from Docker
Consuming Cinder from DockerConsuming Cinder from Docker
Consuming Cinder from Docker
 
Consul and docker swarm cluster
Consul and docker swarm clusterConsul and docker swarm cluster
Consul and docker swarm cluster
 
Octo talk : docker multi-host networking
Octo talk : docker multi-host networking Octo talk : docker multi-host networking
Octo talk : docker multi-host networking
 
The age of orchestration: from Docker basics to cluster management
The age of orchestration: from Docker basics to cluster managementThe age of orchestration: from Docker basics to cluster management
The age of orchestration: from Docker basics to cluster management
 
Vagrant + Docker
Vagrant + DockerVagrant + Docker
Vagrant + Docker
 
Swarm - A Docker Clustering System
Swarm - A Docker Clustering SystemSwarm - A Docker Clustering System
Swarm - A Docker Clustering System
 
Docker Swarm Introduction
Docker Swarm IntroductionDocker Swarm Introduction
Docker Swarm Introduction
 
Introduction to docker swarm
Introduction to docker swarmIntroduction to docker swarm
Introduction to docker swarm
 
Wanting distributed volumes - Experiences with ceph-docker
Wanting distributed volumes - Experiences with ceph-dockerWanting distributed volumes - Experiences with ceph-docker
Wanting distributed volumes - Experiences with ceph-docker
 
Nebulaworks Docker Overview 09-22-2015
Nebulaworks Docker Overview 09-22-2015Nebulaworks Docker Overview 09-22-2015
Nebulaworks Docker Overview 09-22-2015
 
Docker swarm
Docker swarmDocker swarm
Docker swarm
 
Docker Networking & Swarm Mode Introduction
Docker Networking & Swarm Mode IntroductionDocker Networking & Swarm Mode Introduction
Docker Networking & Swarm Mode Introduction
 
Swarm mode
Swarm modeSwarm mode
Swarm mode
 
Couch to OpenStack: Cinder - August 6, 2013
Couch to OpenStack: Cinder - August 6, 2013Couch to OpenStack: Cinder - August 6, 2013
Couch to OpenStack: Cinder - August 6, 2013
 
Introduction to Ansible
Introduction to AnsibleIntroduction to Ansible
Introduction to Ansible
 

Similar to Ubic YAPC 2012

k8s practice 2023.pptx
k8s practice 2023.pptxk8s practice 2023.pptx
k8s practice 2023.pptxwonyong hwang
 
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...Puppet
 
Docker and Puppet for Continuous Integration
Docker and Puppet for Continuous IntegrationDocker and Puppet for Continuous Integration
Docker and Puppet for Continuous IntegrationGiacomo Vacca
 
kubernetes - minikube - getting started
kubernetes - minikube - getting startedkubernetes - minikube - getting started
kubernetes - minikube - getting startedMunish Mehta
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with PuppetKris Buytaert
 
Deep dive in container service discovery
Deep dive in container service discoveryDeep dive in container service discovery
Deep dive in container service discoveryDocker, Inc.
 
K8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingPiotr Perzyna
 
Kubernetes Networking
Kubernetes NetworkingKubernetes Networking
Kubernetes NetworkingCJ Cullen
 
Getting started with kubernetes
Getting started with kubernetesGetting started with kubernetes
Getting started with kubernetesBob Killen
 
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, Orchestration
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, OrchestrationThe Docker "Gauntlet" - Introduction, Ecosystem, Deployment, Orchestration
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, OrchestrationErica Windisch
 
Rasperry Pi and TI CC2650 IPv6 border router
Rasperry Pi and TI CC2650 IPv6 border routerRasperry Pi and TI CC2650 IPv6 border router
Rasperry Pi and TI CC2650 IPv6 border routerNikolaos Monios
 
How to create your own hack environment
How to create your own hack environmentHow to create your own hack environment
How to create your own hack environmentSumedt Jitpukdebodin
 
OSDC.no 2015 introduction to node.js workshop
OSDC.no 2015 introduction to node.js workshopOSDC.no 2015 introduction to node.js workshop
OSDC.no 2015 introduction to node.js workshopleffen
 
Provisioning on Libvirt with Foreman
Provisioning on Libvirt with ForemanProvisioning on Libvirt with Foreman
Provisioning on Libvirt with ForemanNikhil Kathole
 
Kubernetes laravel and kubernetes
Kubernetes   laravel and kubernetesKubernetes   laravel and kubernetes
Kubernetes laravel and kubernetesWilliam Stewart
 
(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines(Declarative) Jenkins Pipelines
(Declarative) Jenkins PipelinesSteffen Gebert
 
A complete guide to Node.js
A complete guide to Node.jsA complete guide to Node.js
A complete guide to Node.jsPrabin Silwal
 

Similar to Ubic YAPC 2012 (20)

Ubic
UbicUbic
Ubic
 
Ubic-public
Ubic-publicUbic-public
Ubic-public
 
k8s practice 2023.pptx
k8s practice 2023.pptxk8s practice 2023.pptx
k8s practice 2023.pptx
 
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
How Puppet Enables the Use of Lightweight Virtualized Containers - PuppetConf...
 
Docker and Puppet for Continuous Integration
Docker and Puppet for Continuous IntegrationDocker and Puppet for Continuous Integration
Docker and Puppet for Continuous Integration
 
kubernetes - minikube - getting started
kubernetes - minikube - getting startedkubernetes - minikube - getting started
kubernetes - minikube - getting started
 
Automating Complex Setups with Puppet
Automating Complex Setups with PuppetAutomating Complex Setups with Puppet
Automating Complex Setups with Puppet
 
Deep dive in container service discovery
Deep dive in container service discoveryDeep dive in container service discovery
Deep dive in container service discovery
 
K8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals TrainingK8s in 3h - Kubernetes Fundamentals Training
K8s in 3h - Kubernetes Fundamentals Training
 
Kubernetes Networking
Kubernetes NetworkingKubernetes Networking
Kubernetes Networking
 
Jenkins Pipelines
Jenkins PipelinesJenkins Pipelines
Jenkins Pipelines
 
Getting started with kubernetes
Getting started with kubernetesGetting started with kubernetes
Getting started with kubernetes
 
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, Orchestration
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, OrchestrationThe Docker "Gauntlet" - Introduction, Ecosystem, Deployment, Orchestration
The Docker "Gauntlet" - Introduction, Ecosystem, Deployment, Orchestration
 
Rasperry Pi and TI CC2650 IPv6 border router
Rasperry Pi and TI CC2650 IPv6 border routerRasperry Pi and TI CC2650 IPv6 border router
Rasperry Pi and TI CC2650 IPv6 border router
 
How to create your own hack environment
How to create your own hack environmentHow to create your own hack environment
How to create your own hack environment
 
OSDC.no 2015 introduction to node.js workshop
OSDC.no 2015 introduction to node.js workshopOSDC.no 2015 introduction to node.js workshop
OSDC.no 2015 introduction to node.js workshop
 
Provisioning on Libvirt with Foreman
Provisioning on Libvirt with ForemanProvisioning on Libvirt with Foreman
Provisioning on Libvirt with Foreman
 
Kubernetes laravel and kubernetes
Kubernetes   laravel and kubernetesKubernetes   laravel and kubernetes
Kubernetes laravel and kubernetes
 
(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines
 
A complete guide to Node.js
A complete guide to Node.jsA complete guide to Node.js
A complete guide to Node.js
 

Recently uploaded

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 

Recently uploaded (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 

Ubic YAPC 2012

  • 1. Friends, this is clean-up time and we're discounting all our silent, electric Ubiks by this much money. Yes' we're throwing away the bluebook. And remember: every Ubik on our lot has been used only as directed. Phillip K. Dick. “Ubik”. Ubic Polymorphic service manager github.com/berekuk/ubic
  • 3. Install Debian/Ubuntu: apt-add-repository ppa:berekuk/ubic && apt-get install ubic FreeBSD: cd /usr/ports/sysutils/p5-Ubic && make install Everywhere else: cpanm Ubic && ubic-admin setup
  • 4. Write service config # cat >/etc/ubic/service/foo use Ubic::Service::SimpleDaemon; Ubic::Service::SimpleDaemon->new( bin => ‘sleep 1000’, stdout => ‘/var/log/foo.log’, );
  • 5. Run it # ubic start foo Starting foo... started (pid 28152)
  • 7. Flexible perl-based polymorphic service manager
  • 9. I’ll talk about APIs instead of features today • Ubic.pm glue code • services • multiservices • service loaders
  • 12. Service state is different from service status # ubic status foo foo running (pid 29551) # kill 29551 # ubic status foo foo not running # ubic stop foo Stopping foo... not running # ubic status foo off
  • 13. Watchdog adjusts service status in accordance with service state. # ubic status foo foo running (pid 29551) # kill 29551 # ubic status foo foo not running # ubic-watchdog foo [Fri Dec 9 03:45:37 2011] foo status is 'not running', restarting
  • 14. Ubic is not a supervisor There is no global supervisor process. Ubic is more similar to init scripts than to upstart or launchd in this aspect.
  • 15. Service state is persistent • state is stored on disk and kept even after reboot • you don’t have to stop services on host shutdown and start them on reboot (I know some people want a proper shutdown; I’ll get to that later)
  • 16. Ubic.pm API consumers • /usr/bin/ubic — command-line frontend • ubic.watchdog service — monitors everything • ubic.ping — reports service status via http
  • 17. Ideas for more features • ubic-web — html app frontend • ‘ubic shutdown’ command which stops everything but don’t change state • parameterized commands
  • 19. Service is an object Services conform to simple API: use parent qw(Ubic::Service); sub start { ... } sub stop { ... } sub status { ... }
  • 20. Start code can get complicated use parent qw(Ubic::Service); sub start { # check if daemon is running # start daemon # sleep for some time # check status # sleep more # check status # ... etc }
  • 21. So Ubic::Service::Skeleton provides shortcuts use parent qw(Ubic::Service::Skeleton); sub start_impl { ... } sub start_impl { ... } sub status_impl { ... } sub timeout_options { start => { step => 0.1, trials => 3 } } }
  • 22. Services inherit from other services Ubic::Service Ubic::Multiservice Ubic::Service::Skeleton Ubic::Service::SimpleDaemon Ubic::Service::InitScriptWrapper Ubic::Service::ZooKeeper Ubic::Service::MongoDB Ubic::Service::Plack Ubic::Service::Memcached Ubic::Service::Starman
  • 23. Custom status() methods Example from Ubic::Service::MongoDB sub status_impl {     my $self = shift;     my $running = check_daemon($self->pidfile);     return result('not running') unless $running;      my $status = MongoDB::Connection->new(...)->admin->run_command({ serverStatus => 1 });     if (!$status->{ok} || $status->{ok} != 1) {         return result('broken');     } else {         return result('running');     } }
  • 24. SimpleDaemon is the most popular service class Ubic::Service::SimpleDaemon->new( bin => ‘plackup /usr/share/foo/app.psgi’, stdout => ‘/var/log/foo.log’, stderr => ‘/var/log/foo.err.log’, ubic_log => ‘/var/log/foo.ubic.log’, user => ‘daemon’, group => ‘daemon’, cwd => ‘/’, env => { PERL5LIB => ‘/usr/share/foo/lib’ }, };
  • 25. Ideas for new service modules • restart (report ‘broken’ status) on memory leaks • or on code changes • or once per N seconds • or if service doesn’t answer http ping (parameterize with url, port and timeout)
  • 26. More ideas for new service modules • better mechanism for adding features (decorators/roles/middlewares) • simple daemonizer which uses Proc::Daemon instead of Ubic::Daemon • wrappers for other service managers (turn daemontools service to ubic service)
  • 28. All services belong to the global service tree # ubic status foo running (pid 1234) bar running (pid 1235) ubic ubic.ping running (pid 2182) ubic.update running (pid 2181) ubic.watchdog running (pid 1996)
  • 29. Files in service dir describe services with perl code # cat /etc/ubic/service/foo use Ubic::Service::SimpleDaemon; Ubic::Service::SimpleDaemon->new( bin => ‘sleep 1000’, stdout => ‘/var/log/foo.log’, );
  • 30. Subdirectories become multiservices # ls ~/ubic/service/ubic/ ping update watchdog # ubic status ubic ubic ubic.ping running (pid 2182) ubic.update running (pid 2181) ubic.watchdog running (pid 1996)
  • 31. Or you can implement multiservice in perl # cat /etc/ubic/service/psgi use parent qw(Ubic::Multiservice); use Ubic::Service::Plack; sub simple_service { my ($self, $name) = @_; return Ubic::Service::Plack->new(...); } sub service_names { my @configs = glob “/psgi_apps/*.psgi”; s{^/psgi_apps(.*).psgi$}{$1} for @configs; return @configs; }
  • 32. Another use case: create N services use Ubic::Multiservice::Simple; use Ubic::Service::SimpleDaemon; return Ubic::Multiservice::Simple->new({     map {         "worker$_" => Ubic::Service::SimpleDaemon->new({             bin => "/usr/bin/worker.pl",         })     } (1..10) });
  • 33. Ideas for more multiservices • bind the whole /etc/init.d/ or /service/ to ubic • “stash” multiservice — create services from command-line without creating any configs
  • 35. Configs with .ini extension are different # cat /etc/ubic/service/foo.ini module = Ubic::Service::SimpleDaemon [options] bin = sleep 1000 stdout = /var/log/foo.log
  • 36. Configs with any extension are different • ini configs are loaded with Ubic::ServiceLoader::Ext::ini • experimental yaml service loader is in separate repo (not sure if extra dependency is worth it)
  • 37. Now we can reach to non-perl users • Node.JS guys at Yandex use Ubic • Java guys at Yandex use Ubic • admins who don’t know Perl use Ubic • all of them do it because they like it, not because I forced them :) • tell your non-perl friends about Ubic today!
  • 38. Ideas for more service loaders • .bin — turn symlink to binary into service • new [addons] section to ini config, which would wrap service object in listed decorators • .xml, .json (I know we don’t need so many of different formats, but Node.JS people like to reinvent the wheel)
  • 40. There are no cross-platform service managers • Let’s port Ubic to Windows! • several guys tried to help but disappeared • github.com/berekuk/Ubic/wiki/Windows is the current plan
  • 41. Plugins • add a new command to /usr/bin/ubic • or add memory leaks monitoring to all services at once • API: apply the given middleware to all services
  • 43. Questions? Patches? github.com/berekuk/Ubic #ubic at irc.perl.org “Like” Ubic on metacpan: metacpan.org/release/Ubic
  • 44. This is the slide #42

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n