SlideShare uma empresa Scribd logo
1 de 39
Baixar para ler offline
Stress-free
Deployment
Rob Allen
Rob Allen http://akrabat.comIPC ’09
Rob Allen?
Rob Allen http://akrabat.comIPC ’09
Why automate
deployment?
Rob Allen http://akrabat.comIPC ’09
Getting your house in
order
Rob Allen http://akrabat.comIPC ’09
Source code control
Rob Allen http://akrabat.comIPC ’09
Branch!
• Branch every new feature
• (that includes bug fixes)
• Be ready go live at all times
• Trunk deployment
• Live branch deployment
Rob Allen http://akrabat.comIPC ’09
Trunk deployment
Rob Allen http://akrabat.comIPC ’09
Live branch deployment
Rob Allen http://akrabat.comIPC ’09
What do I do?
Rob Allen http://akrabat.comIPC ’09
Database
considerations
Rob Allen http://akrabat.comIPC ’09
One master database
• Live database holds master structure
• Copy master to everywhere else
• Advantages:
• Simple to implement
• Disadvantages:
• Backwards compatibility required
• Doesnʼt scale for multiple devs well
• Easy to make mistakes
Rob Allen http://akrabat.comIPC ’09
Migrations
• Versioned schemas
• Use delta files with UP and DOWN functions
• Advantages:
• version controlled
• destructive changes possible
• Disadvantages:
• Canʼt think of any!
• Tools:
• DbDeploy, LiquiBase, Doctrine, homebrew script
Rob Allen http://akrabat.comIPC ’09
Code
considerations
Rob Allen http://akrabat.comIPC ’09
Context awareness
• Configuration based on where the code has been
deployed
• Automatic detection based on URL?
• Environment variable set in vhost defintion?
Rob Allen http://akrabat.comIPC ’09
So whatĘźs deployment
all about?
Rob Allen http://akrabat.comIPC ’09
Things to think about
• Transport to server
• FTP? rsync? svn checkout? svn export?
• File permissions
• Preserve user uploaded files
• Steps after upload
• Stale cache?
• Cache priming?
Rob Allen http://akrabat.comIPC ’09
Server organisation
• Much easier if you control vhosts
• For multiple sites on same server:
• You want predictable file locations for all sites
• e.g:
• /home/www/{site name}/live/current
• /home/www/{site name}/staging/current
Rob Allen http://akrabat.comIPC ’09
The deployment plan
Rob Allen http://akrabat.comIPC ’09
Typical steps
• Tag this release
• Set “under maintenance” page
• Transfer files to server
• Set file permissions as required
• Delete old cache files
• Run database migrations if required
• Remove “under maintenance” page
Rob Allen http://akrabat.comIPC ’09
HereĘźs mine:
• Branch trunk to release-{yymmdd-hhmm}
• ssh into server
• Ensure staging is up to date (svn st -u)
• If not, stop here!
• svn checkout new release branch to a new
folder in live directory
• Set permissions on the /tmp folder for cache
les
Rob Allen http://akrabat.comIPC ’09
Deployment plan cont.
• Switch “current” symlink to new directory
Rob Allen http://akrabat.comIPC ’09
Tools for automation
Rob Allen http://akrabat.comIPC ’09
Simple scripts
• PHP, Bash or Bat files
• Simple to write and run
• Generally easier to run on the correct server
• Execute command line apps via exec()
Rob Allen http://akrabat.comIPC ’09
Example script
$cmd = "svn cp -m "Tag for automatic deployment"
$baseUrl/$website/trunk $baseUrl/$website/tags/$date";
ob_start();
system($cmd, $returnValue);
$output = ob_get_clean();
if (0 < $returnValue) {
throw new Exception("Tagging failed.n" . $output);
}
echo "Tagged to $daten";
Rob Allen http://akrabat.comIPC ’09
Phing
• PHP based build system based on Ant
• XML configuration files
• PEAR installation
• Integration with Subversion and DbDeploy
• Expects to run build.xml in current directory
• build.properties contains config info
Rob Allen http://akrabat.comIPC ’09
Phing philosophy"
• Like make, build scripts consist of targets
• Targets can depend on other targets
• “live” depends on “tag”, “checkout”, “migrate”
• Each target does the minimum it can
e.g.
• Create svn tag
• checkout files to destination
• migrate database
Rob Allen http://akrabat.comIPC ’09
Example build.xml
<?xml version="1.0" encoding="UTF-8" ?>
<project name="BRIBuild" default="deploy" basedir=".">
<tstamp>
<format property="date" pattern="%Y%m%d-%H%M" />
</tstamp>
<property file="build.properties" />
<property name="trunkpath" value="${svnpath}/${website}/trunk" />
<property name="tagpath" value="${svnpath}/${website}/tags/${date}" />
<target name="deploy" depends="tag" />
<target name="tag" description="Tag trunk">
<exec command="svn cp -m 'Tag for automatic deployment'
${trunkpath} ${tagpath}" />
<echo msg="Tagged trunk to ${date}" />
</target>
</project>
Rob Allen http://akrabat.comIPC ’09
My deployment system
Rob Allen http://akrabat.comIPC ’09
deploy.php
~$ deploy.php 23100
BRI server side deploy script
Version 1.1, 2009
Found /home/domains/bigroom/live/
Tagging to 20091030-2303... done
Deploying 20091030-2303 ... done
Changing symlink to new checkout
Cleaning up older checkouts
23100 successfully deployed to /home/domains/bigroom/live/
Rob Allen http://akrabat.comIPC ’09
Our server layout
Rob Allen http://akrabat.comIPC ’09
deploy.php
• Custom PHP script
• Relies on environment variable: WWW_DIR
• Advantages:
• Custom designed to fit our way of working
• PHP! Quick and easy to write.
• Disadvantages:
• Hard to alter for a specific server
• Hard to change methodology
Rob Allen http://akrabat.comIPC ’09
FTP deployments
<project name="project" basedir="." default="deploy">
<property file="build.properties" />
<property name="trunkpath" value="${svnpath}/${website}/trunk" />
<fileset dir="${exportdir}/" id="files">
<include name="**/*" />
</fileset>
<target name="deploy" depends="svnexport,ftp-upload" />
<target name="svnexport">
<delete dir="${exportdir}" />
<svnexport
username="${username}" password="${password}"
nocache="true" force="true"
repositoryurl="${trunkpath}" todir="${exportdir}" />
</target>
Rob Allen http://akrabat.comIPC ’09
FTP deployments
<target name="ftp-upload">
<echo msg="Deploying application files" />
<ftpdeploy
host="${ftp.host}" port="${ftp.port}"
username="${ftp.username}" password="${ftp.password}"
dir="${ftp.dir}">
<fileset refid="${files}" />
</ftpdeploy>
</target>
</project>
Rob Allen http://akrabat.comIPC ’09
FTP with Phing
• Per-website build.xml for custom deployments
• Advantages:
• Leverages other peopleʼs experiences
• Was very fast to create
• Integrates with xinc
• Disadvantages:
• New technology to be learnt
• Phing beta and Pear_Version_SVN alpha
Rob Allen http://akrabat.comIPC ’09
Rollback
Rob Allen http://akrabat.comIPC ’09
Emergency roll-back
Just change the symlink!
Rob Allen http://akrabat.comIPC ’09
Complete roll-back
• Write rollback.php or create a Phing build task
• Put the server back to where it was before
• Change the symlink
• Delete the deployed directory
• Database rollback
• Run down() delta in your migration tool
To summarise
1. Automated deployment prevents mistakes
2. ItĘźs not hard
3. Easy roll-back is priceless
Rob Allen http://akrabat.comIPC ’09
Thank you
Please provide feedback on this talk: http://joind.in/1039

Mais conteĂşdo relacionado

Destaque

Programação em c# (117 horas)
Programação em c# (117 horas)Programação em c# (117 horas)
Programação em c# (117 horas)Vitor Savicki
 
Summary - Transformational-Generative Theory
Summary - Transformational-Generative TheorySummary - Transformational-Generative Theory
Summary - Transformational-Generative TheoryMarielis VI
 
Transformational-Generative Grammar
Transformational-Generative GrammarTransformational-Generative Grammar
Transformational-Generative GrammarRuth Ann Llego
 
Deep structure and surface structure
Deep structure and surface structureDeep structure and surface structure
Deep structure and surface structureAsif Ali Raza
 
Resposta do curso bradesco j2me
Resposta do curso bradesco j2meResposta do curso bradesco j2me
Resposta do curso bradesco j2me118452
 
Estatistica aplicada exercicios resolvidos manual tecnico formando
Estatistica aplicada exercicios resolvidos manual tecnico formandoEstatistica aplicada exercicios resolvidos manual tecnico formando
Estatistica aplicada exercicios resolvidos manual tecnico formandoAntonio Mankumbani Chora
 
Generative Design and Design Hacking
Generative Design and Design HackingGenerative Design and Design Hacking
Generative Design and Design HackingDesignit
 

Destaque (7)

Programação em c# (117 horas)
Programação em c# (117 horas)Programação em c# (117 horas)
Programação em c# (117 horas)
 
Summary - Transformational-Generative Theory
Summary - Transformational-Generative TheorySummary - Transformational-Generative Theory
Summary - Transformational-Generative Theory
 
Transformational-Generative Grammar
Transformational-Generative GrammarTransformational-Generative Grammar
Transformational-Generative Grammar
 
Deep structure and surface structure
Deep structure and surface structureDeep structure and surface structure
Deep structure and surface structure
 
Resposta do curso bradesco j2me
Resposta do curso bradesco j2meResposta do curso bradesco j2me
Resposta do curso bradesco j2me
 
Estatistica aplicada exercicios resolvidos manual tecnico formando
Estatistica aplicada exercicios resolvidos manual tecnico formandoEstatistica aplicada exercicios resolvidos manual tecnico formando
Estatistica aplicada exercicios resolvidos manual tecnico formando
 
Generative Design and Design Hacking
Generative Design and Design HackingGenerative Design and Design Hacking
Generative Design and Design Hacking
 

Mais de elliando dias

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slideselliando dias
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScriptelliando dias
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structureselliando dias
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de containerelliando dias
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agilityelliando dias
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Librarieselliando dias
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!elliando dias
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Webelliando dias
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduinoelliando dias
 
Minicurso arduino
Minicurso arduinoMinicurso arduino
Minicurso arduinoelliando dias
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorceryelliando dias
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Designelliando dias
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makeselliando dias
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojureelliando dias
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.elliando dias
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebookelliando dias
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Studyelliando dias
 
From Lisp to Clojure/Incanter and RAn Introduction
From Lisp to Clojure/Incanter and RAn IntroductionFrom Lisp to Clojure/Incanter and RAn Introduction
From Lisp to Clojure/Incanter and RAn Introductionelliando dias
 

Mais de elliando dias (20)

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
 
Ragel talk
Ragel talkRagel talk
Ragel talk
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
 
Minicurso arduino
Minicurso arduinoMinicurso arduino
Minicurso arduino
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
 
Rango
RangoRango
Rango
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
 
From Lisp to Clojure/Incanter and RAn Introduction
From Lisp to Clojure/Incanter and RAn IntroductionFrom Lisp to Clojure/Incanter and RAn Introduction
From Lisp to Clojure/Incanter and RAn Introduction
 

Último

#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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
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
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
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
 
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
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
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
 

Último (20)

#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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
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
 
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...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
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
 
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
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
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
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
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
 

Stress Free Deployment

  • 2. Rob Allen http://akrabat.comIPC ’09 Rob Allen?
  • 3. Rob Allen http://akrabat.comIPC ’09 Why automate deployment?
  • 4. Rob Allen http://akrabat.comIPC ’09 Getting your house in order
  • 5. Rob Allen http://akrabat.comIPC ’09 Source code control
  • 6. Rob Allen http://akrabat.comIPC ’09 Branch! • Branch every new feature • (that includes bug xes) • Be ready go live at all times • Trunk deployment • Live branch deployment
  • 7. Rob Allen http://akrabat.comIPC ’09 Trunk deployment
  • 8. Rob Allen http://akrabat.comIPC ’09 Live branch deployment
  • 9. Rob Allen http://akrabat.comIPC ’09 What do I do?
  • 10. Rob Allen http://akrabat.comIPC ’09 Database considerations
  • 11. Rob Allen http://akrabat.comIPC ’09 One master database • Live database holds master structure • Copy master to everywhere else • Advantages: • Simple to implement • Disadvantages: • Backwards compatibility required • DoesnĘźt scale for multiple devs well • Easy to make mistakes
  • 12. Rob Allen http://akrabat.comIPC ’09 Migrations • Versioned schemas • Use delta les with UP and DOWN functions • Advantages: • version controlled • destructive changes possible • Disadvantages: • CanĘźt think of any! • Tools: • DbDeploy, LiquiBase, Doctrine, homebrew script
  • 13. Rob Allen http://akrabat.comIPC ’09 Code considerations
  • 14. Rob Allen http://akrabat.comIPC ’09 Context awareness • Conguration based on where the code has been deployed • Automatic detection based on URL? • Environment variable set in vhost dention?
  • 15. Rob Allen http://akrabat.comIPC ’09 So whatĘźs deployment all about?
  • 16. Rob Allen http://akrabat.comIPC ’09 Things to think about • Transport to server • FTP? rsync? svn checkout? svn export? • File permissions • Preserve user uploaded les • Steps after upload • Stale cache? • Cache priming?
  • 17. Rob Allen http://akrabat.comIPC ’09 Server organisation • Much easier if you control vhosts • For multiple sites on same server: • You want predictable le locations for all sites • e.g: • /home/www/{site name}/live/current • /home/www/{site name}/staging/current
  • 18. Rob Allen http://akrabat.comIPC ’09 The deployment plan
  • 19. Rob Allen http://akrabat.comIPC ’09 Typical steps • Tag this release • Set “under maintenance” page • Transfer les to server • Set le permissions as required • Delete old cache les • Run database migrations if required • Remove “under maintenance” page
  • 20. Rob Allen http://akrabat.comIPC ’09 HereĘźs mine: • Branch trunk to release-{yymmdd-hhmm} • ssh into server • Ensure staging is up to date (svn st -u) • If not, stop here! • svn checkout new release branch to a new folder in live directory • Set permissions on the /tmp folder for cache les
  • 21. Rob Allen http://akrabat.comIPC ’09 Deployment plan cont. • Switch “current” symlink to new directory
  • 22. Rob Allen http://akrabat.comIPC ’09 Tools for automation
  • 23. Rob Allen http://akrabat.comIPC ’09 Simple scripts • PHP, Bash or Bat les • Simple to write and run • Generally easier to run on the correct server • Execute command line apps via exec()
  • 24. Rob Allen http://akrabat.comIPC ’09 Example script $cmd = "svn cp -m "Tag for automatic deployment" $baseUrl/$website/trunk $baseUrl/$website/tags/$date"; ob_start(); system($cmd, $returnValue); $output = ob_get_clean(); if (0 < $returnValue) { throw new Exception("Tagging failed.n" . $output); } echo "Tagged to $daten";
  • 25. Rob Allen http://akrabat.comIPC ’09 Phing • PHP based build system based on Ant • XML conguration les • PEAR installation • Integration with Subversion and DbDeploy • Expects to run build.xml in current directory • build.properties contains cong info
  • 26. Rob Allen http://akrabat.comIPC ’09 Phing philosophy" • Like make, build scripts consist of targets • Targets can depend on other targets • “live” depends on “tag”, “checkout”, “migrate” • Each target does the minimum it can e.g. • Create svn tag • checkout les to destination • migrate database
  • 27. Rob Allen http://akrabat.comIPC ’09 Example build.xml <?xml version="1.0" encoding="UTF-8" ?> <project name="BRIBuild" default="deploy" basedir="."> <tstamp> <format property="date" pattern="%Y%m%d-%H%M" /> </tstamp> <property file="build.properties" /> <property name="trunkpath" value="${svnpath}/${website}/trunk" /> <property name="tagpath" value="${svnpath}/${website}/tags/${date}" /> <target name="deploy" depends="tag" /> <target name="tag" description="Tag trunk"> <exec command="svn cp -m 'Tag for automatic deployment' ${trunkpath} ${tagpath}" /> <echo msg="Tagged trunk to ${date}" /> </target> </project>
  • 28. Rob Allen http://akrabat.comIPC ’09 My deployment system
  • 29. Rob Allen http://akrabat.comIPC ’09 deploy.php ~$ deploy.php 23100 BRI server side deploy script Version 1.1, 2009 Found /home/domains/bigroom/live/ Tagging to 20091030-2303... done Deploying 20091030-2303 ... done Changing symlink to new checkout Cleaning up older checkouts 23100 successfully deployed to /home/domains/bigroom/live/
  • 30. Rob Allen http://akrabat.comIPC ’09 Our server layout
  • 31. Rob Allen http://akrabat.comIPC ’09 deploy.php • Custom PHP script • Relies on environment variable: WWW_DIR • Advantages: • Custom designed to t our way of working • PHP! Quick and easy to write. • Disadvantages: • Hard to alter for a specic server • Hard to change methodology
  • 32. Rob Allen http://akrabat.comIPC ’09 FTP deployments <project name="project" basedir="." default="deploy"> <property file="build.properties" /> <property name="trunkpath" value="${svnpath}/${website}/trunk" /> <fileset dir="${exportdir}/" id="files"> <include name="**/*" /> </fileset> <target name="deploy" depends="svnexport,ftp-upload" /> <target name="svnexport"> <delete dir="${exportdir}" /> <svnexport username="${username}" password="${password}" nocache="true" force="true" repositoryurl="${trunkpath}" todir="${exportdir}" /> </target>
  • 33. Rob Allen http://akrabat.comIPC ’09 FTP deployments <target name="ftp-upload"> <echo msg="Deploying application files" /> <ftpdeploy host="${ftp.host}" port="${ftp.port}" username="${ftp.username}" password="${ftp.password}" dir="${ftp.dir}"> <fileset refid="${files}" /> </ftpdeploy> </target> </project>
  • 34. Rob Allen http://akrabat.comIPC ’09 FTP with Phing • Per-website build.xml for custom deployments • Advantages: • Leverages other peopleĘźs experiences • Was very fast to create • Integrates with xinc • Disadvantages: • New technology to be learnt • Phing beta and Pear_Version_SVN alpha
  • 35. Rob Allen http://akrabat.comIPC ’09 Rollback
  • 36. Rob Allen http://akrabat.comIPC ’09 Emergency roll-back Just change the symlink!
  • 37. Rob Allen http://akrabat.comIPC ’09 Complete roll-back • Write rollback.php or create a Phing build task • Put the server back to where it was before • Change the symlink • Delete the deployed directory • Database rollback • Run down() delta in your migration tool
  • 38. To summarise 1. Automated deployment prevents mistakes 2. ItĘźs not hard 3. Easy roll-back is priceless
  • 39. Rob Allen http://akrabat.comIPC ’09 Thank you Please provide feedback on this talk: http://joind.in/1039