SlideShare a Scribd company logo
UBIC
http://github.com/berekuk/ubic
UBIC
Toolkit for writing daemons, init scripts
          and services in perl.

          Batteries included.
case "$1" in
                                        Usual way
start)
 check_for_no_start
 check_privsep_dir
    echo -n "Starting OpenBSD Secure Shell server: sshd"
 start-stop-daemon --start --quiet --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS
    echo "."
 ;;
stop)
    echo -n "Stopping OpenBSD Secure Shell server: sshd"
 start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/sshd.pid
    echo "."
 ;;

reload|force-reload)
 check_for_no_start
 check_config
    echo -n "Reloading OpenBSD Secure Shell server's configuration"
 start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd
 echo "."
 ;;

restart)
 check_privsep_dir
 check_config
    echo -n "Restarting OpenBSD Secure Shell server: sshd"
 start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile /var/run/sshd.pid
 check_for_no_start
 start-stop-daemon --start --quiet --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS
 echo "."
 ;;

*)
 echo "Usage: /etc/init.d/ssh {start|stop|reload|force-reload|restart}"
Usual way
   They are ugly.
 They are verbose.
They are full of hacks.
Usual way
                  ...and they don’t work consistently:
root@v5114:/etc/init.d# /etc/init.d/nscd start
Starting Name Service Cache Daemon: nscd (already running).

root@v5114:~# /etc/init.d/cron start
Starting periodic command scheduler: crond failed!

root@v5114:~# /etc/init.d/ssh start
root@v5114:~# SD Secure Shell server: sshdroot@v5114:~#

root@v5114:/etc/init.d# /etc/init.d/nscd status
Status of Name Service Cache Daemon service: not running.

root@v5114:/etc/init.d# /etc/init.d/cron status
Usage: /etc/init.d/cron {start|stop|restart|reload|force-reload}.

root@v5114:/etc/init.d# /etc/init.d/ssh status
Usage: /etc/init.d/ssh {start|stop|reload|force-reload|restart}
Better way
root # cat /etc/ubic/service/sleeping-daemon
use Ubic::Service::SimpleDaemon;

Ubic::Service::SimpleDaemon->new({
     bin => '/bin/sleep 1000',
});
Better way
root # ubic start sleeping-daemon
Starting sleeping-daemon... started

root # ubic start sleeping-daemon
Starting sleeping-daemon... already running

root # ubic status
sleeping-daemon
   running
ubic-ping
 running
LSB 4.0 conformance
 http://refspecs.freestandards.org/LSB_4.0.0/LSB-Core-
        generic/LSB-Core-generic/iniscrptact.html
start
start the service
stop
stop the service
restart
stop and restart the service if the service is already running, otherwise start the service
try-restart
restart the service if the service is already running
reload
cause the configuration of the service to be reloaded without actually stopping and
restarting the service
force-reload
cause the configuration to be reloaded if the service supports this, otherwise restart the
service if it is running
status
print the current status of the service
Hierarchical services
mmcleric $ ubic status
Not a root, printing cached statuses
ubic-ping
 running
yandex
  yandex.swift-blogs-a
 running
  yandex.swift-blogs-b
 running
  yandex.swift-blogs-c
 running
  yandex.swift-blogs-d
 running
  yandex.swift-blogs-e
 running
yandex-ppb-bulca-ds
  yandex-ppb-bulca-ds.bulca_items
 running
  yandex-ppb-bulca-ds.bulca_items_retry
    off
  yandex-ppb-bulca-ds.index_blogs
 running
  yandex-ppb-bulca-ds.merge_swift
 running
yandex-ppb-cache
  yandex-ppb-cache.swift-blogs
     yandex-ppb-cache.swift-blogs.lighttpd
 running
     yandex-ppb-cache.swift-blogs.fastcgi
 running
Hierarchical services
root # ubic restart -f yandex-ppb-cache
yandex
  Restarting yandex.swift-blogs-a... restarted
  Restarting yandex.swift-blogs-b... restarted
  Restarting yandex.swift-blogs-c... restarted
  Restarting yandex.swift-blogs-d... restarted
  Restarting yandex.swift-blogs-e... restarted
SysV init scripts
root # cat /etc/init.d/sleeping-daemon
#!/usr/bin/perl
use Ubic::Run; # that’s all!
Watchdog
root # killall sleep

root # ubic status
sleeping-daemon not running
ubic-ping       running

root # ubic-watchdog
[ Fri Jun 11 03:06:32 2010 ]
sleeping-daemon is broken, restarting
HTTP ping
mmcleric $ wget -q -O - 'http://localhost:12345/status/service/sleeping-
daemon'
ok

mmcleric $ wget -O - 'http://localhost:12345/status/service/abc'
--03:31:21-- http://localhost:12345/status/service/abc
       => `-'
Resolving localhost... 127.0.0.1
Connecting to localhost|127.0.0.1|:12345... connected.
HTTP request sent, awaiting response... 404 Not found
03:31:21 ERROR 404: Not found.
Non-root users
root # cat /etc/ubic/service/sleeping-daemon
use Ubic::Service::SimpleDaemon;

Ubic::Service::SimpleDaemon->new({
     bin => '/bin/sleep 1000',
      user => 'nobody',
});
Common classes
mmcleric $ cat /etc/ubic/service/something
...
Ubic::Service::Common->new({
    start => sub {
       start_daemon({
           bin    => '/usr/bin/something’,
           pidfile => '/var/tmp/something.pid',
           stdout => "/var/log/something.log",
           stderr => "/var/log/something.err.log",
           ubic_log => "/var/log/something.ubic.log",
       });
    },
    stop => sub {
       stop_daemon('/var/log/something.pid');
    },
    status => sub {
       check_daemon('/var/log/something.pid') ? 'running' : 'not running';
    },
    user => 'www-data',
});
Common classes
mmcleric $ cat /etc/ubic/service/something
...
Ubic::Service::PSGI->new({
    server => 'Starman',
    app => '/usr/share/something.psgi',
    server_args => { workers => 3,
               port => $port },
    app_name => "something",
    port   => $port,
    ubic_log => "$log_dir/ubic.log",
    stdout => "$log_dir/stdout.log",
    stderr => "$log_dir/stderr.log",
    user    => "www-data",
});
Common classes
    Ubic::Service::Common
     Ubic::Service::Lighttpd
   Ubic::Service::Memcached
   Ubic::Service::ProcManager
       Ubic::Service::PSGI
  Ubic::Service::SimpleDaemon
     Ubic::Service::Skeleton

     (not all of them are on cpan - yet)
Statistics
  Usage in Yandex:
23 different packages
     19 clusters
      457 hosts
Credits
             UBIC:
http://github.com/berekuk/ubic
http://search.cpan.org/dist/Ubic

               Me:
 Vyacheslav Matyukhin, Yandex
http://friendfeed.com/mmcleric
    mailto:me@berekuk.ru
 jabber:mmcleric@gmail.com

More Related Content

What's hot

Testing your infrastructure with litmus
Testing your infrastructure with litmusTesting your infrastructure with litmus
Testing your infrastructure with litmus
Bram Vogelaar
 
Ansible tips & tricks
Ansible tips & tricksAnsible tips & tricks
Ansible tips & tricks
bcoca
 
Instruction: dev environment
Instruction: dev environmentInstruction: dev environment
Instruction: dev environment
Soshi Nemoto
 
Bootstrapping multidc observability stack
Bootstrapping multidc observability stackBootstrapping multidc observability stack
Bootstrapping multidc observability stack
Bram Vogelaar
 
Ansible leveraging 2.0
Ansible leveraging 2.0Ansible leveraging 2.0
Ansible leveraging 2.0
bcoca
 
Integrating icinga2 and the HashiCorp suite
Integrating icinga2 and the HashiCorp suiteIntegrating icinga2 and the HashiCorp suite
Integrating icinga2 and the HashiCorp suite
Bram Vogelaar
 
Integrating icinga2 and the HashiCorp suite
Integrating icinga2 and the HashiCorp suiteIntegrating icinga2 and the HashiCorp suite
Integrating icinga2 and the HashiCorp suite
Bram Vogelaar
 
Asynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time MessagingAsynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time Messaging
Steve Rhoades
 
Ansible fest Presentation slides
Ansible fest Presentation slidesAnsible fest Presentation slides
Ansible fest Presentation slides
Aaron Carey
 
Docker command
Docker commandDocker command
Docker command
Eric Ahn
 
Creating Reusable Puppet Profiles
Creating Reusable Puppet ProfilesCreating Reusable Puppet Profiles
Creating Reusable Puppet Profiles
Bram Vogelaar
 
Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestration
bcoca
 
Ansible - Introduction
Ansible - IntroductionAnsible - Introduction
Ansible - Introduction
Stephane Manciot
 
Streams are Awesome - (Node.js) TimesOpen Sep 2012
Streams are Awesome - (Node.js) TimesOpen Sep 2012 Streams are Awesome - (Node.js) TimesOpen Sep 2012
Streams are Awesome - (Node.js) TimesOpen Sep 2012 Tom Croucher
 
Hacking ansible
Hacking ansibleHacking ansible
Hacking ansible
bcoca
 
Top Node.js Metrics to Watch
Top Node.js Metrics to WatchTop Node.js Metrics to Watch
Top Node.js Metrics to Watch
Sematext Group, Inc.
 
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
How to Develop Puppet Modules: From Source to the Forge With Zero ClicksHow to Develop Puppet Modules: From Source to the Forge With Zero Clicks
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
Carlos Sanchez
 
Observability with Consul Connect
Observability with Consul ConnectObservability with Consul Connect
Observability with Consul Connect
Bram Vogelaar
 
Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2
Brian Schott
 
Configuration Management in Ansible
Configuration Management in Ansible Configuration Management in Ansible
Configuration Management in Ansible
Bangladesh Network Operators Group
 

What's hot (20)

Testing your infrastructure with litmus
Testing your infrastructure with litmusTesting your infrastructure with litmus
Testing your infrastructure with litmus
 
Ansible tips & tricks
Ansible tips & tricksAnsible tips & tricks
Ansible tips & tricks
 
Instruction: dev environment
Instruction: dev environmentInstruction: dev environment
Instruction: dev environment
 
Bootstrapping multidc observability stack
Bootstrapping multidc observability stackBootstrapping multidc observability stack
Bootstrapping multidc observability stack
 
Ansible leveraging 2.0
Ansible leveraging 2.0Ansible leveraging 2.0
Ansible leveraging 2.0
 
Integrating icinga2 and the HashiCorp suite
Integrating icinga2 and the HashiCorp suiteIntegrating icinga2 and the HashiCorp suite
Integrating icinga2 and the HashiCorp suite
 
Integrating icinga2 and the HashiCorp suite
Integrating icinga2 and the HashiCorp suiteIntegrating icinga2 and the HashiCorp suite
Integrating icinga2 and the HashiCorp suite
 
Asynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time MessagingAsynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time Messaging
 
Ansible fest Presentation slides
Ansible fest Presentation slidesAnsible fest Presentation slides
Ansible fest Presentation slides
 
Docker command
Docker commandDocker command
Docker command
 
Creating Reusable Puppet Profiles
Creating Reusable Puppet ProfilesCreating Reusable Puppet Profiles
Creating Reusable Puppet Profiles
 
Ansible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife OrchestrationAnsible - Swiss Army Knife Orchestration
Ansible - Swiss Army Knife Orchestration
 
Ansible - Introduction
Ansible - IntroductionAnsible - Introduction
Ansible - Introduction
 
Streams are Awesome - (Node.js) TimesOpen Sep 2012
Streams are Awesome - (Node.js) TimesOpen Sep 2012 Streams are Awesome - (Node.js) TimesOpen Sep 2012
Streams are Awesome - (Node.js) TimesOpen Sep 2012
 
Hacking ansible
Hacking ansibleHacking ansible
Hacking ansible
 
Top Node.js Metrics to Watch
Top Node.js Metrics to WatchTop Node.js Metrics to Watch
Top Node.js Metrics to Watch
 
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
How to Develop Puppet Modules: From Source to the Forge With Zero ClicksHow to Develop Puppet Modules: From Source to the Forge With Zero Clicks
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
 
Observability with Consul Connect
Observability with Consul ConnectObservability with Consul Connect
Observability with Consul Connect
 
Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2Using Ansible Dynamic Inventory with Amazon EC2
Using Ansible Dynamic Inventory with Amazon EC2
 
Configuration Management in Ansible
Configuration Management in Ansible Configuration Management in Ansible
Configuration Management in Ansible
 

Viewers also liked

A Unique Business Blogging Strategy
A Unique Business Blogging StrategyA Unique Business Blogging Strategy
A Unique Business Blogging Strategy
Christine Rochelle
 
A 3-869e531bc383bc2db2d9e22b083ea95f5f0fa454-141125232253-conversion-gate02
A 3-869e531bc383bc2db2d9e22b083ea95f5f0fa454-141125232253-conversion-gate02A 3-869e531bc383bc2db2d9e22b083ea95f5f0fa454-141125232253-conversion-gate02
A 3-869e531bc383bc2db2d9e22b083ea95f5f0fa454-141125232253-conversion-gate02Chris Humphreys
 
Build Your Business Blog - Christine Rochelle
Build Your Business Blog - Christine RochelleBuild Your Business Blog - Christine Rochelle
Build Your Business Blog - Christine Rochelle
Christine Rochelle
 
DMSC - Automotive SEO Content Follow Up Webinar
DMSC - Automotive SEO Content Follow Up WebinarDMSC - Automotive SEO Content Follow Up Webinar
DMSC - Automotive SEO Content Follow Up Webinar
Christine Rochelle
 
The Hutchinson’S Landscape 2010’
The  Hutchinson’S  Landscape 2010’The  Hutchinson’S  Landscape 2010’
The Hutchinson’S Landscape 2010’biznurse
 
How to-add-clickable-links-to-slideshare
How to-add-clickable-links-to-slideshareHow to-add-clickable-links-to-slideshare
How to-add-clickable-links-to-slideshareChris Humphreys
 
MK Valenti Before And After
MK Valenti Before And AfterMK Valenti Before And After
MK Valenti Before And After
mkvalenti
 
Morpheus configuration engine (slides from Saint Perl-2 conference)
Morpheus configuration engine (slides from Saint Perl-2 conference)Morpheus configuration engine (slides from Saint Perl-2 conference)
Morpheus configuration engine (slides from Saint Perl-2 conference)
Vyacheslav Matyukhin
 
Business Entrepreneurs
Business EntrepreneursBusiness Entrepreneurs
Business EntrepreneursCarly Taylor
 
Writing is My Therapy Because I Have No Money For Drugs
Writing is My Therapy Because I Have No Money For DrugsWriting is My Therapy Because I Have No Money For Drugs
Writing is My Therapy Because I Have No Money For DrugsChristine Rochelle
 
A Cohesive Social Media Strategy
A Cohesive Social Media StrategyA Cohesive Social Media Strategy
A Cohesive Social Media Strategy
Christine Rochelle
 
Manufacturing Pasts - 16th June 2012
Manufacturing Pasts - 16th June 2012Manufacturing Pasts - 16th June 2012
Manufacturing Pasts - 16th June 2012taniarowlett
 
3 Social Strategies Your Brand is Missing
3 Social Strategies Your Brand is Missing3 Social Strategies Your Brand is Missing
3 Social Strategies Your Brand is Missing
Christine Rochelle
 
Ubic slides (Moscow.pm meeting, Nov 2010)
Ubic slides (Moscow.pm meeting, Nov 2010)Ubic slides (Moscow.pm meeting, Nov 2010)
Ubic slides (Moscow.pm meeting, Nov 2010)Vyacheslav Matyukhin
 
How to add clickable links to slideshare
How to add clickable links to slideshareHow to add clickable links to slideshare
How to add clickable links to slideshareChris Humphreys
 
Love’em Or Lose’em
Love’em Or Lose’emLove’em Or Lose’em
Love’em Or Lose’em
Bogdan
 
Twitter 101 For Car Dealers
Twitter 101 For Car DealersTwitter 101 For Car Dealers
Twitter 101 For Car Dealers
Christine Rochelle
 

Viewers also liked (18)

A Unique Business Blogging Strategy
A Unique Business Blogging StrategyA Unique Business Blogging Strategy
A Unique Business Blogging Strategy
 
A 3-869e531bc383bc2db2d9e22b083ea95f5f0fa454-141125232253-conversion-gate02
A 3-869e531bc383bc2db2d9e22b083ea95f5f0fa454-141125232253-conversion-gate02A 3-869e531bc383bc2db2d9e22b083ea95f5f0fa454-141125232253-conversion-gate02
A 3-869e531bc383bc2db2d9e22b083ea95f5f0fa454-141125232253-conversion-gate02
 
Build Your Business Blog - Christine Rochelle
Build Your Business Blog - Christine RochelleBuild Your Business Blog - Christine Rochelle
Build Your Business Blog - Christine Rochelle
 
DMSC - Automotive SEO Content Follow Up Webinar
DMSC - Automotive SEO Content Follow Up WebinarDMSC - Automotive SEO Content Follow Up Webinar
DMSC - Automotive SEO Content Follow Up Webinar
 
The Hutchinson’S Landscape 2010’
The  Hutchinson’S  Landscape 2010’The  Hutchinson’S  Landscape 2010’
The Hutchinson’S Landscape 2010’
 
How to-add-clickable-links-to-slideshare
How to-add-clickable-links-to-slideshareHow to-add-clickable-links-to-slideshare
How to-add-clickable-links-to-slideshare
 
MK Valenti Before And After
MK Valenti Before And AfterMK Valenti Before And After
MK Valenti Before And After
 
Morpheus configuration engine (slides from Saint Perl-2 conference)
Morpheus configuration engine (slides from Saint Perl-2 conference)Morpheus configuration engine (slides from Saint Perl-2 conference)
Morpheus configuration engine (slides from Saint Perl-2 conference)
 
Uitnodiging
UitnodigingUitnodiging
Uitnodiging
 
Business Entrepreneurs
Business EntrepreneursBusiness Entrepreneurs
Business Entrepreneurs
 
Writing is My Therapy Because I Have No Money For Drugs
Writing is My Therapy Because I Have No Money For DrugsWriting is My Therapy Because I Have No Money For Drugs
Writing is My Therapy Because I Have No Money For Drugs
 
A Cohesive Social Media Strategy
A Cohesive Social Media StrategyA Cohesive Social Media Strategy
A Cohesive Social Media Strategy
 
Manufacturing Pasts - 16th June 2012
Manufacturing Pasts - 16th June 2012Manufacturing Pasts - 16th June 2012
Manufacturing Pasts - 16th June 2012
 
3 Social Strategies Your Brand is Missing
3 Social Strategies Your Brand is Missing3 Social Strategies Your Brand is Missing
3 Social Strategies Your Brand is Missing
 
Ubic slides (Moscow.pm meeting, Nov 2010)
Ubic slides (Moscow.pm meeting, Nov 2010)Ubic slides (Moscow.pm meeting, Nov 2010)
Ubic slides (Moscow.pm meeting, Nov 2010)
 
How to add clickable links to slideshare
How to add clickable links to slideshareHow to add clickable links to slideshare
How to add clickable links to slideshare
 
Love’em Or Lose’em
Love’em Or Lose’emLove’em Or Lose’em
Love’em Or Lose’em
 
Twitter 101 For Car Dealers
Twitter 101 For Car DealersTwitter 101 For Car Dealers
Twitter 101 For Car Dealers
 

Similar to Ubic

Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slidesharetomcopeland
 
Puppet @ Seat
Puppet @ SeatPuppet @ Seat
Puppet @ Seat
Alessandro Franceschi
 
Pursue container architecture with mincs
Pursue container architecture with mincsPursue container architecture with mincs
Pursue container architecture with mincs
Yuki Nishiwaki
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newYiwei Ma
 
PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22
Yuya Takei
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next Frontier
Carlos Sanchez
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
Simon Su
 
FreeBSD: Dev to Prod
FreeBSD: Dev to ProdFreeBSD: Dev to Prod
FreeBSD: Dev to Prod
Sean Chittenden
 
ByPat博客出品Lvs+keepalived
ByPat博客出品Lvs+keepalivedByPat博客出品Lvs+keepalived
ByPat博客出品Lvs+keepalivedredhat9
 
Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)
Ben Hall
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
Docker, Inc.
 
Infrastructure = code - 1 year later
Infrastructure = code - 1 year laterInfrastructure = code - 1 year later
Infrastructure = code - 1 year later
Christian Ortner
 
Control your deployments with Capistrano
Control your deployments with CapistranoControl your deployments with Capistrano
Control your deployments with Capistrano
Ramazan K
 
Virtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + PuppetVirtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + PuppetOmar Reygaert
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
Омские ИТ-субботники
 
Harmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and PuppetHarmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and Puppet
Achieve Internet
 
Linux Du Jour
Linux Du JourLinux Du Jour
Linux Du Jour
mwedgwood
 

Similar to Ubic (20)

Railsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshareRailsconf2011 deployment tips_for_slideshare
Railsconf2011 deployment tips_for_slideshare
 
infra-as-code
infra-as-codeinfra-as-code
infra-as-code
 
Cooking with Chef
Cooking with ChefCooking with Chef
Cooking with Chef
 
Puppet @ Seat
Puppet @ SeatPuppet @ Seat
Puppet @ Seat
 
Pursue container architecture with mincs
Pursue container architecture with mincsPursue container architecture with mincs
Pursue container architecture with mincs
 
X64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 newX64服务器 lnmp服务器部署标准 new
X64服务器 lnmp服务器部署标准 new
 
PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next Frontier
 
Docker in Action
Docker in ActionDocker in Action
Docker in Action
 
FreeBSD: Dev to Prod
FreeBSD: Dev to ProdFreeBSD: Dev to Prod
FreeBSD: Dev to Prod
 
Puppet
PuppetPuppet
Puppet
 
ByPat博客出品Lvs+keepalived
ByPat博客出品Lvs+keepalivedByPat博客出品Lvs+keepalived
ByPat博客出品Lvs+keepalived
 
Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)Running Docker in Development & Production (#ndcoslo 2015)
Running Docker in Development & Production (#ndcoslo 2015)
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
 
Infrastructure = code - 1 year later
Infrastructure = code - 1 year laterInfrastructure = code - 1 year later
Infrastructure = code - 1 year later
 
Control your deployments with Capistrano
Control your deployments with CapistranoControl your deployments with Capistrano
Control your deployments with Capistrano
 
Virtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + PuppetVirtualization and automation of library software/machines + Puppet
Virtualization and automation of library software/machines + Puppet
 
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
 
Harmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and PuppetHarmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and Puppet
 
Linux Du Jour
Linux Du JourLinux Du Jour
Linux Du Jour
 

Recently uploaded

Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 

Recently uploaded (20)

Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 

Ubic

  • 2. UBIC Toolkit for writing daemons, init scripts and services in perl. Batteries included.
  • 3. case "$1" in Usual way start) check_for_no_start check_privsep_dir echo -n "Starting OpenBSD Secure Shell server: sshd" start-stop-daemon --start --quiet --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS echo "." ;; stop) echo -n "Stopping OpenBSD Secure Shell server: sshd" start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/sshd.pid echo "." ;; reload|force-reload) check_for_no_start check_config echo -n "Reloading OpenBSD Secure Shell server's configuration" start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd echo "." ;; restart) check_privsep_dir check_config echo -n "Restarting OpenBSD Secure Shell server: sshd" start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile /var/run/sshd.pid check_for_no_start start-stop-daemon --start --quiet --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS echo "." ;; *) echo "Usage: /etc/init.d/ssh {start|stop|reload|force-reload|restart}"
  • 4. Usual way They are ugly. They are verbose. They are full of hacks.
  • 5. Usual way ...and they don’t work consistently: root@v5114:/etc/init.d# /etc/init.d/nscd start Starting Name Service Cache Daemon: nscd (already running). root@v5114:~# /etc/init.d/cron start Starting periodic command scheduler: crond failed! root@v5114:~# /etc/init.d/ssh start root@v5114:~# SD Secure Shell server: sshdroot@v5114:~# root@v5114:/etc/init.d# /etc/init.d/nscd status Status of Name Service Cache Daemon service: not running. root@v5114:/etc/init.d# /etc/init.d/cron status Usage: /etc/init.d/cron {start|stop|restart|reload|force-reload}. root@v5114:/etc/init.d# /etc/init.d/ssh status Usage: /etc/init.d/ssh {start|stop|reload|force-reload|restart}
  • 6. Better way root # cat /etc/ubic/service/sleeping-daemon use Ubic::Service::SimpleDaemon; Ubic::Service::SimpleDaemon->new({ bin => '/bin/sleep 1000', });
  • 7. Better way root # ubic start sleeping-daemon Starting sleeping-daemon... started root # ubic start sleeping-daemon Starting sleeping-daemon... already running root # ubic status sleeping-daemon running ubic-ping running
  • 8. LSB 4.0 conformance http://refspecs.freestandards.org/LSB_4.0.0/LSB-Core- generic/LSB-Core-generic/iniscrptact.html start start the service stop stop the service restart stop and restart the service if the service is already running, otherwise start the service try-restart restart the service if the service is already running reload cause the configuration of the service to be reloaded without actually stopping and restarting the service force-reload cause the configuration to be reloaded if the service supports this, otherwise restart the service if it is running status print the current status of the service
  • 9. Hierarchical services mmcleric $ ubic status Not a root, printing cached statuses ubic-ping running yandex yandex.swift-blogs-a running yandex.swift-blogs-b running yandex.swift-blogs-c running yandex.swift-blogs-d running yandex.swift-blogs-e running yandex-ppb-bulca-ds yandex-ppb-bulca-ds.bulca_items running yandex-ppb-bulca-ds.bulca_items_retry off yandex-ppb-bulca-ds.index_blogs running yandex-ppb-bulca-ds.merge_swift running yandex-ppb-cache yandex-ppb-cache.swift-blogs yandex-ppb-cache.swift-blogs.lighttpd running yandex-ppb-cache.swift-blogs.fastcgi running
  • 10. Hierarchical services root # ubic restart -f yandex-ppb-cache yandex Restarting yandex.swift-blogs-a... restarted Restarting yandex.swift-blogs-b... restarted Restarting yandex.swift-blogs-c... restarted Restarting yandex.swift-blogs-d... restarted Restarting yandex.swift-blogs-e... restarted
  • 11. SysV init scripts root # cat /etc/init.d/sleeping-daemon #!/usr/bin/perl use Ubic::Run; # that’s all!
  • 12. Watchdog root # killall sleep root # ubic status sleeping-daemon not running ubic-ping running root # ubic-watchdog [ Fri Jun 11 03:06:32 2010 ] sleeping-daemon is broken, restarting
  • 13. HTTP ping mmcleric $ wget -q -O - 'http://localhost:12345/status/service/sleeping- daemon' ok mmcleric $ wget -O - 'http://localhost:12345/status/service/abc' --03:31:21-- http://localhost:12345/status/service/abc => `-' Resolving localhost... 127.0.0.1 Connecting to localhost|127.0.0.1|:12345... connected. HTTP request sent, awaiting response... 404 Not found 03:31:21 ERROR 404: Not found.
  • 14. Non-root users root # cat /etc/ubic/service/sleeping-daemon use Ubic::Service::SimpleDaemon; Ubic::Service::SimpleDaemon->new({ bin => '/bin/sleep 1000', user => 'nobody', });
  • 15. Common classes mmcleric $ cat /etc/ubic/service/something ... Ubic::Service::Common->new({ start => sub { start_daemon({ bin => '/usr/bin/something’, pidfile => '/var/tmp/something.pid', stdout => "/var/log/something.log", stderr => "/var/log/something.err.log", ubic_log => "/var/log/something.ubic.log", }); }, stop => sub { stop_daemon('/var/log/something.pid'); }, status => sub { check_daemon('/var/log/something.pid') ? 'running' : 'not running'; }, user => 'www-data', });
  • 16. Common classes mmcleric $ cat /etc/ubic/service/something ... Ubic::Service::PSGI->new({ server => 'Starman', app => '/usr/share/something.psgi', server_args => { workers => 3, port => $port }, app_name => "something", port => $port, ubic_log => "$log_dir/ubic.log", stdout => "$log_dir/stdout.log", stderr => "$log_dir/stderr.log", user => "www-data", });
  • 17. Common classes Ubic::Service::Common Ubic::Service::Lighttpd Ubic::Service::Memcached Ubic::Service::ProcManager Ubic::Service::PSGI Ubic::Service::SimpleDaemon Ubic::Service::Skeleton (not all of them are on cpan - yet)
  • 18. Statistics Usage in Yandex: 23 different packages 19 clusters 457 hosts
  • 19. Credits UBIC: http://github.com/berekuk/ubic http://search.cpan.org/dist/Ubic Me: Vyacheslav Matyukhin, Yandex http://friendfeed.com/mmcleric mailto:me@berekuk.ru jabber:mmcleric@gmail.com

Editor's Notes