Postgis in the Open Cloud

Video in TIB AV-Portal: Postgis in the Open Cloud

Formal Metadata

Postgis in the Open Cloud
Writing portable open Source mapping applications with LEAFLET and OPENSHIFT
Alternative Title
Writing portable postgreSQL-backed applications for the Open Cloud
Title of Series
Number of Parts
CC Attribution 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Release Date
Production Place
Ottawa, Canada

Content Metadata

Subject Area
Instant Mapping Applications with PostGIS and Nodejs Learn how to write PostgreSQL-backed applications that can be automatically cloned, built, monitored, and scaled in a matter of minutes. We'll walk you through all of the steps involved in developing and scaling your own Node.js-powered PostGIS mapping application on the OpenShift cloud hosting platform. By the end of this talk, you should be able to instantly deploy your own PostgreSQL-backed network applications to your own public or private cloud in a single command. This talk includes a brief architectural overview of OpenShift, a freely-available Open Source hosting platform. Folks who want to follow along should bring their own laptop with git, rubygems, and nodejs installed & available.
effective Java Map time open com Heads stack favourite languages web odds Services option different memory box conversation extent scripting services Map map build Lasten software developers open source bit Sass Variables portable open photo CPU series rights board virtualized results Router stability slides App open source software developers response connection machines Store code portable Twitter terms operation networks hardware environmental Cat optimization platform operations research response scale information surface content interaction databases stack ups Limit GRASS Application Tubes URLs environmental networks Case hardware platform
effective code time format open web management static Services different clones box Frameworks vertical cartridge allocation Nintendo architectures network programming format bit open types cartridge Frameworks configurable rights Load Balancer read page point track servers file open source Link machines Store scalability number versions specific Memory terms internets Ideals service platform multi shift Red Hat front end Java content Application indexing Word allocation environmental service
point page Headers Flows servers file Java state content IP-Adressen Biomedical Imaging static round different filesystem Console Sum of Games scripting modules addition default response Standards screen help blocking list virtualization lines Menge Scanner statistics Heads indexing este Frameworks configurable editors rights read
effective administration sources zoom open clients Heads different localizations Link Map map software developers Extremwerte portable languages specific messaging job Ordering Frameworks figures point content delivery network slides file open source variety TRANSFORMATION mass events specific selection App data processing default Standards information Resolution tile servers interface Net content code Menge Limit Application call URLs environmental Query Case function Standards binds bottom Drag code view time parameter part IP-Adressen favourite Mathematical eggs box Frameworks model cartridge areas scripting Headers format Variables configurable rights results recording App functionality servers browsers portable Attribute versions write causal strings Console installations modules response dialect shift projection Graphs Bounds interaction databases including indexing events password blog posts
connections App servers environmental Source code Application Variables portable IP-Adressen call number
collaboration unit call namespaces Variables Application portable DNS URLs vector environmental Counterpane's Source code rights address
open source root password strings list Source code databases cartridge part connections
Headers slides momentum file software developers encoding time generics Sun communication URLs strings repositories shell Source code Console gamma localizations messaging sources guide binds code com menu break Variables Application connections including environmental cartridge Ordering Systems
point Thread open source file code tokenizer similar open IP-Adressen portable Variables train different strings Source code environmental configurable platform conditions modules shift Relation key software developers open source list Sass Menge Variables Application portable several connections URLs job environmental Ordering configurable rights localizations
graphs key tokenizer Sort Source code environmental configurable Variables
laptops Headers summand software developers lines image directories GRASS number domains URLs Cache repositories shell Source code Console environmental protocols SSH localizations messaging interface sources guide code clients menu bit REST API break Variables environmental cartridge compilation Systems clones
slides App code state sources machines similar count shift hypothesis URLs Services different Sort repositories Source code representation Console job gamma localizations messaging addition map demos fake software developers guide Neighbourhoods code bit break Variables GRASS portable types causal job environmental key Systems localizations
meta servers Map administration domains URLs repositories Source code Console SSH lips localizations messaging sharing sources services software developers guide open source code break portable connections including URLs environmental blog posts Systems clones
laptops servers Link Map ones databases indication Sort RING Source code office lips services information software developers databases effective Application indexing environmental mix rights remote Tabulated Systems clones
Intel build effective code sources ones databases indication part energy hook different automative cartridge extent errors scripting aliases page traction part several connections job Ordering iOS remote figures task results point Software Engineer slides functionality App modules file encoding DoT Slam translations RING jump frame batch inherits Java code databases effective indexing bootstrap Query normierten Räumen Tabulated
point App interface Link open source scale time image zoom GRASS Stäbe areas MACH domains web URLs Chain memory Source code clones sources demos Venn diagrams FDDI page mass Limit Application call fans CAN environmental cartridge Ordering website results Chat reverse-engineering
App statistics servers file Link time view sources Theories scalability number wiki strings operation Source code cartridge conversation World Wide Web Consortium App focus Algorithmen scale information demos servers software developers constructor databases bit heck Menge Variables statistics connections redundancies wiki environmental Buffers configurable rights iterators
regression trees installations patches databases open Replicant Application Amicable numbers configurable cartridge default architectures servers Complexity open source list statistics call Replicant single including URLs environmental cartridge versions platform current address
architectures regression trees Link information patches image sigma projection core indication help Menge com cartridge platform Methode der partiellen kleinsten Quadrate law cartridge
App App shift evaluation Map help open source Extremwerte databases lines Sum of task
from spent so far pretty good or bad people have been working on the slide so that to the last minute like get pushed this stuff like to the Web like about 20 minutes ago so that's all I'm glad I missed the other toxins fortunately I know it's it's great it's really nice right get started here so today I'm doing a talk on POS GIS in the Open Cloud and all define kind of what I mean by open cloud in a minute and they were specifically going to be writing and highly portable source mapping applications using leaflet and little bit OpenShift but I there's a bitterly URL in a full URL if if you guys are interested in following along the you can you can literally open up the slides and there is no excuse is all of you guys could have a mapping out by the end of this talk we can have however many people here are all fully deployed and sharing URL so really cool stuff but I don't know if you have a set up a full of PostgreSQL database in under an hour or you know deployed a whole act you know on top of that right so this is a lot a lot of cool content and all of trying to cram it all into the 45 minutes here 0 you back a new world like to try to write it up on the surface of white board here there was some truck is the that URL that 1 T P B QG it and its case sensitive so watch out for that there's the there's the slides to N was go so I'm Ryan you can also find me is Ryan J. on our IIsi Twitter I get home and or Ryan J. at redhat . com I work at Red Hat on their OpenShift team doing kind of cloud there's the cloud stuff and we got a lot of really exciting stuff I'm going to show you a little bit of a little bit odd stuff and a lot of Canada application technology that I that I built on top of it using a lot of fun post cheapos Crespo's GIS stuff and so all start off with kind of that open cloud overview give you a little bit of background for people who are new to open source cloud technologies and if you guys wanna follow along and try to build an app during this workshop so you could select from many different languages I mostly since we have a limited amount of time I'm just going to focus on Java script and no JS so hopefully that's interesting for you guys and if not then we have the same solution written in Python and the same solution as written in Java and so you could refer to a couple different example codes and take a look and hopefully get some useful out of it and will add leaflet for a client-side map interactions will build a simple API to install and configure post those grass post GIS and extensions and use environment variables bootstrap a database launched an instant mapping solution and learn about the tuning your database I really hope get that all the stuff and the out a of flip through the slides quick if you have any questions feel free to shout amount rigid and uh whatever and I'll do my best to answer it and also the clouds what is it what is the cloud and you know there's a lot of difference explanations mostly cat photos maybe have but when you're talking about building the cloud of it with open source tools there's a couple of big kind components you want you want to use so infrastructure as a Service is a term hopefully you guys have heard of before this companies like you know Amazon Web Services in easy to and basically offers there's there's a lot of other companies that offer a kind of a whole box on demand or a virtual machine on demand right and usually these are virtualized environments it's composed of a bunch of hardware of course and then the software you're going to use is going to be something like OpenStack eucalyptus is another open-source infrastructure-as-a-service cloud stack salts that these all good options my favorite is OpenStack and hence that the end result of an for infrastructures services you have easy on on-demand Linux environments for whole boxers right but my criticism of infrastructures services it's kind of like a conversation between 1 sky guy and another guy where 1 the vendor and once a consumer and they've really can I left developers completely out of the conversation here's a whole box that's not configured at all you go ahead and configure it and then do the work to maintain it right and that's the real like when you run into a dead end on these things is you can come out with you can quickly customize a box but what happens when you need to maintain that and keep it up-to-date becomes a lot more work as so platforms is a service so that really helps open source the workflows between your operations team and your development team I usually there's a lot of contention between these 2 groups because they have a competing goals operations team wants to optimize ramp up time it not using too many resources not spinning up too much hardware and they want keep the cost low and developers wanna just do everything as quickly as possible and not have to wait for the ops team to respond so we're gonna basically show you workflows for building hosting and scaling those are the main 3 things at Platform as a Service is going to try to solve for you and there's a lot of technical under the headings of how that works I can give you more information if you want to have some slightly it's a little bit more details in these slides so in this case the data is the operations guy and Luke Skywalker of that that's how you perceive things but Skywalker is running around trying to make set up that you know these guys can finally work together on each really working toward the angles without without hurting each other and you know the great thing about this is the discussion ends up Shifting Towards good policies for how to do auto-scaling in response to demand instead of saying that OK are you done with that BMI needed memory back of the CPU's back at you don't have this fighting back and forth because you're hardware scales automatically in response to the amount of network load CPU load so that's kind of what we're
trying to do some terminology warning that the son of reads like this is Red Hat specific time so we have a couple pieces to how we do Platform as a Service with 2 different machine types we've got a broker that does orchestration and then we have another machine type called a node and what we do with those nodes it's basically a whole box and we carve out and see Linux Containers and then we use that c groups to make a user permission the user and a resource scope and each application that's running on top of this platform is kind of its own and we call that a collection of resources built with the Linux and see groups will call that ideal for lack of a better word and so and so your application is going to run inside this gear environment and then we could clone nose and load balance across multiple gears so that's the idea cartridges are kind of our metaphor for extending what you have on a gear and and sometimes for example if I was running PostgreSQL I would probably wanna put my application in a scalable configurations what that'll do is it'll put the DVD on a separated year so it has the full read full of amount of resource allocation just for the DB and it's not trying to share it with the web server right we you do non-scalable both be bundled together on the same gear so you have low latency but it's not quite scalable and also that scalable configuration like simple clone the front end we don't clone the back and yet but all have some some slides on that later so we do
have a open cartridge format if you if anyone's interested in developing and add-ons for open shifts click on this link I made this graphic myself but not the Nintendo prefer a Nintendo nerves suffer Nintendo Seal of Approval I edited says open source I think it's anyone recognizes this mean normally it it's a trap right that's 1 thing you wanna worry about it is that there is a common name on the internet aboral admirac passing at the track right now so you know do you wanna invest all your time of of reformatting your code to work on a platform as a service maybe maybe not maybe boxes are good enough for you and the reason why saying seems legitimacy is we have that kind of no lock-in and you can use its it's open source and we have to have 3 different releases of OpenShift there's so origin that's all of our open source code with a hosted version called OpenShift online and then there's enterprise version the the running around in your own data and and I think that is all I have for well maybe a little bit more but I'll try to keep it open content to a minimum and keep it on the post stuff so frameworks and these are my starting point for you guys to get running get up up and going with a new applications and so for no JS I recommend using these micro frameworks that the term it's going around but I like using the rest 5 for node j if you wanted to get started this has kind of like a really simple and based application in here and I also have a really simple flask based application that basically just has a web server number dependencies file and it already has some of basic API that just responds on index . html to serve up your your main Web page and also has static assets support for serving static assets so those are a couple great starting points from that you're going to want to use but you could also flask is available for PHP 0 accusing silex is really simple for Ruby there's us Sinatra and so those are all great starting points and we'll get into specifically looking at some of the words that go into full
screen and block me and
so here is the base and have some convinced that screens getting trapped some configs stuff over here as static acetyl going this folder on this index . html file and then the 2 main really critical things for no JS is you want to have a package . J sound file that's going to indicate your list of dependencies this has dependencies on the configure module and on ratified so really simple and it also has something in here that tells your server how to start itself to run whenever you run in PM states start that'll automatically run no server right OpenShift actually reads from this 1 here remains so you want have whatever your main script is annotated there in your package such a son and by default we the default is to load server . JRC you could leave those lines out where you're saying specifically server . js as long as you name your server server . js if you wanna name anything else you want to go back and package such a son in an editor here's a basic but you know you can see I'm using require up at the top and that's global keyword and jails to load in PM packages so requiring the configured module Rats Defy and then FS is a built-in module 4 of reading and writing the file system this is 1 of the things that is unique to to node j ust that you don't get standard java script both that require as well as in a standard JavaScript you can interact with file system so that some of the nice stuff at the server-side JavaScript will give you access to them so you can see here we have a couple rounds defined there's a a status page that just sends a OK response for status API and point and then on our main point slashed wages return index . html and do some old switcheroo with the host and port setting I think this for local the flow but you also have down here this is loading up serving all your static anything that's in static get served up its CSS JavaScript the image files and here's how we start the server and the only thing really unique to open 15 years that we're passing in the IP address in addition to the port that's not always defined with Java scripts or with no JS but OpenShift runger each AP on a different IP virtual IP so you know want to make sure to include the IP address and I'll give will see the configured file later on but that's a kind of brief intro
to what you can expect from some of these micro frameworks and so you could do get clone on this and have that be a starting point if you want to try to pack along with the slides and copy and paste content and it's so language-specific dependency so Ruby has RubyGems pipeline as Python eggs no JS has these in here modules and opens Schipol automatically if you have a detailed will automatically pull down these requirements and make them available to your app and you could also I think check these dependencies into your source code there a debate on you know do you wanna check in new dependencies are not for no j it's actually recommended to check in your model dependencies into your source code but if they're not checked and will will populate those is part of the build process and so you want also add some language-specific database findings so for no JS and this is how you would install something from the command line inside your project Indian install PG query dash dash saved you run that it'll add it to your package . on file and listed as a dependency so that helps keep whether you check in your node modules that's where the the things he will into whether you check all those or not use the dash dash saving always keep your package duchies on up to date and same thing for Python there's a settings stockpile or requirements . text you want have have you had a dependencies listed in there too in order to maximize portability right so for no j has using them as a guy on the idea of Brian C. reusing Brian Caesar PG query module 1 and that really makes this stuff it's just standard post GI standard PostgreSQL's and then of function handlers and that's really it's really simple and so for local development if you wanted spend up a local server with with the base project or with a completed project you run Indian install at install dependencies locally if you haven't yet and then Indian start that stands out whatever is dictated in your package that Jason files alright leaflet so how many people have used leaflet before anyone heard of leaflet only how OK are leaflet is 1 of my favorites of mapping solutions it's fully open-source it uses openstreetmap for the titles but you can also modify it to use other map tiles and it has a very simple interface and excellent documentation and I would highly recommend that you guys take a look at the docks because it got yeah what a great stuff and we'll take a look at some of the code next if you wanted to use leaflet in your head you could just slap this India index . J is the index . html but this in your header and you know basically has a style sheet some draw the script that leaflets use and loading this right from leaflets CDN here and so to initialize your map but this you wanna put in a script tag at but this near the bottom of my my index file but and there's basically a map variable that you can initialize you'll set the view to some coordinates and here it just have hard coded to my neighborhood and in the same Francisco Bay area and then there's the final value here is the zoom the amount is in you want and and we'll take a look at what this looks like in a minute but you also have that looks like this is adding a tile layer so here I'm using standard tiles instead of OpenStreetMap tiles Molly did was change this URL and so if you wanna use OpenStreetMap so you could put their URL and there's a variety of different tiles solutions you could load in here I'm and then I have some attribution here you wanna make sure you give people credit officially open source projects in a given given credit for all the work they're doing so I give credit stand in and out of the the data that included into the map I think the data that they're talking about is the city names are scaled relative to population size and so that's the data quote and quote just a city names but there's someone data processing that went into the a scaling the name and that was basically the data from OpenStreetMap so next a next step we actually want to redraw the map when ever someone does a zoom drag or when the map locates right here is our 3 up top we've got these 3 actions that we wanna respond to and then I have them down here here's the actual functions and setting up some event triggers and I'm saying whenever whenever leaflet detects a zoom event or a drag events for a new map comes on whenever any of those 3 events fire off I am going to run this get function and its passing in EU the the events that fired off the browser I'm gonna ask the map to get its bounds and say what's the the top right in the bottom left corner and it'll get those 2 mapping points pulled out from the screen and and then it'll construct a URL here and then will just run out get URL because J. query or something that you wary and then will users spend map function to process the results of whatever comes back from our server so we haven't defined what we haven't defined as in point you would be looking for parks slash with then is and what we're right on the server side and so for now this is going to fail right but not yet
eventually when when these maps and come back will clear the current events and then wants to the mass pretty simple right any questions about that not much to ask about real real clean and so let's build an API for our map to talk to and here's some of the looks similar to the base application that I started with right we have the configure we have addressed 5 we have at best only thing that's new here is I have a model called DDP . js that's going to handle all of our DB interactions are in 1 mark up my main server file with all this DVD specific code so separated that into a different module and then here I am doing create server of causes to allow cross-site requests from I have a couple points here here let's get all the parks with and will just 1 dB select box whenever the parts within in point is that so this this mapping the URL to a function call and will take a look at a function in a minute but this is how easy it is to define endpoints API endpoints with a micro framework and this is true whether you're using flask whether you're using Silex for PHP whether you're using JAX-RS for job or Sinatra for Ruby it's gonna look similar to this and I already talked about the other stuff in this file so I'll skip ahead will take a look at setting up close graphs so if you already have an existing open shifts application environment you can run a command like this cartridge had RHC is our command line tool you can install that with regions that you run gem install RHC you sign up for a voltage if the counterpose Jerome OpenShift cluster somewhere and then you could say add PostgreSQL 8 4 was the version we start as well and we're currently have 92 available and I don't know the specifics of release on that that's 9 9 to 12 or something but then we could look it up if you guys know the figures need specifics on them and yeah there's more information at POS Grassmann to blog posts but that's how easy it is to if if someone from the uh basically these cartridges allow developers to say I need this dependency and it becomes available as part of the application and here is the so let's just assume that just worked post-crisis available right but it seemed like it skipped over something that right and but that the database is available let's look at that DB file that I defined and see how we're gonna run queries and so here we have that select box function that I mentioned whenever we run slash parks slash with then it's going to hit this function here and so here this request response and next is kind of a standard function parameters on any any API response from either express or testified in those micro micro-framework the request Req variable is going to be the request rest is your response you could name was whatever you want and so so and I think next is if you have something like a WebSocket you can kind of keep a continued socket open on here and so I am going to basically look up the query strings from the request will pass the URL all try to pull out the last 1 and long 1 lap to belong to and and I also check if someone passed in limit parameter that way the client can do throttling if you're on a mobile device they could say I only want 20 map points at a time right don't give me 15 thousand map points again overwhelm eyebrows right so I put that limit parameter and for a client-side throttling them and I think I see is in the code here I have in the earlier here query limit 40 hours of putting the fault of 40 someone could override the default limit but that's that that was a sensible default Billy's gives you 40 map and this is something to look at and people can manually but that but there were more so here is the response and then send back and in case they missed any of these parameters if they don't have lat long that's that's missing a sentiment their response and and if it's all available I use that PG module to make my query so here PG is that the module that I required earlier and then i'm just gonna run a select and here I have a transformer and it's trendy I doesn't it it does sorry I'm really tired of super weight on this stuff but it basically does the geospatial query ends up from the 4 3 2 6 is that the format of the data I think right yeah yeah OK yeah so you can check with him if you have questions had at that at that time any other questions about this slide then this is gonna send back the rows that we got right pretty simple map men map the query get the rows and then return back to the back to the map from them so how did all this get wired together how am I talking to PostgreSQL with just this PG variable i didn't specify the IP address and specify the admin password or the user name any of that stuff there hasn't been in any of our code right we wanna have clean and portable code and there is nothing coded so far which is good but some major gaps right so let's take a look at where did that stuff what would happened that stuff so here
all all do well on doing a are RHC at creates and all say my app and there no JS that to me felt create thanks OK so here is going to create my application I just did no
JS here but that's
already going to spend up yeah new app for me and it's going to have some environment variables predefined within this application and you saw how I was connecting to the IP address of the server and there is also a lot of port number in there and server . listen call when we set up a server earlier so this will come back
with some of some environment variables that will be able to use and when that command completes you could also look up any the environments later by running RHC actio show vector might be able to do that already OK you have
is ready here it's making the DNS available here is my at 2 was the name of the AP I picked this namespace earlier for all of my applications you could use your you could use your Git Hub username you're Iousy handle your and your e-mail address or whatever you want for your name space there and then if you wanted to do team collaboration you could assign a team member of right privileges the update privileges SSH access on your subdomain so here you can see we have a URL already available there's SSH address we can
ssh into that we have a get remote and a local copy of our source here in the MyApp twofold here's our local source I could do RHC SSH to connect to this thing over ssh ends I
can also run RHC
show to see the details his the same details from earlier echoed back right and if I
had pose PostgreSQL sold it
would also have on this do that right now RHC cartridge had PostgreSQL 9 . 2 and will add that to our node book post-growth uh this q well that that's not a full list there that's just the list of gasses stroganoffs online when you know if I was part of the text that but that's a partial list of some cartridges based on what I typed OK here we go we got our user root password database name the connection string by came up pretty quick right and now if I go back
to this SSH environment momenta need log in again because the environment variables for connecting the PostgreSQL added after this shell session got started so here I could SSH back in time I could use just standard SSH as well but RHC SSH is kind of a shortcut that that runs SSH and along connection string you get some earlier so here I could do V and then grep for something like DB so here's all my DB connection strings that my applications can use so you write your applications to refer to environment variables in order to keep your code clean and so let's take a look at
the configured file I have that's stress the 5 days that's fine post yeah true have this slide as well and
here is the configured file and basically created as a module this is what the configured module for node as expects and have a similar file for flask my flask application and might with the application as well and so this has a lot of conditional assignments 1st it checks for a process . the port of Inferno as processes your main thread the training even your environment relative that process and open should doesn't define . hold we don't define port parochial does so theoretically this might yield run on her roku but maybe not I haven't actually tried so probably but it I would love to have these be super portable applications to any open cloud platform not just a Red Hat 1 right but this is how you fiction many different environment variable is as you want and in order to populate the configured . port variable and we're also going to populate an IP address and we're going to have a connection string for PostgreSQL all these have a back at the end and here's our sensible fallback for local development so if I run this local data it's going to start up on 1 27 . 0 0 . 1 4 3 thousand by running on open shift in the environment variables are available it'll take advantage of the environment variables by run it somewhere else and they have different environment variables I included in this file and my code instantly can run on either the platform right and so this is 1 of the keys to writing year old true portable Stokoe code that'll run just about anywhere and if you could also set custom environment variables so 1 thing that like a lot of applications have a Google Analytics tracker key you don't necessarily want a hard code that and your source right specially together the point of several different URL so so you can specify this as here I have a secret tokens with a bunch of junk in here right I
could run even set secret token it sets my environment variable could do e in the list I could see it's populated there and if I go
back to SSH and connects I'll have to reload the session but I could check in and that secret key would also be populated in here in the graph secret there is the same same secret tokens right
so that's another way to keep
your code super nice and clean and if you want any helpful that are C E in the hell of a lot of detail what I'm doing this with OpenShift online so this is why right now this like 8 anyone can go to this
URL up top right now with your cellphones anything anyone yeah 0 yeah that's all I have yeah this this here
is running on my
laptop here and setting the environment so and I also had
a shell open as well
so here's yeah yeah yeah yeah and the way that works is that users of this this command line tool using is talking to open has a REST API so you could there's a lot more that you can do with the rest API if you really wanted you heavy automation of that REST API has the most number of features the command line has a little bit less and then we have a web interface as well and the web interface you can set these environment variables uh so that's 1 thing I'd really love to see added into the the weather it's yes it's good question and OK so
let's get back to the
slides are environment variables OK here you could even supplied additional environment variables during your app creation process so unfortunately this is a demo I was working on for Code for America they have app called adopt the hydrant and it basically maps all the fire hydrants in in town and the problem was when it snowed is fire hydrants would get covered up in a bunch of snow and someone would need to dig map and so they had neighborhood representatives that would volunteer I'm going to adopt this hydrogen and then they had kind of a social app where you could see hey so and so is maintaining that they you know they have all these neighborhood volunteers are filling the gap you know uh between for a lack of government services right and you really have citizen-driven applications that that a really powerful and this is exactly the type of thing you would want the portable but they also spun this in Hawaii instead of there's no snow there but they have a the sirens that alert alert you if there's a synonymy warnings and they had all these birds that were nesting in the sirens and they would need to go key thesis that tsunami alert sirens clean of of all these nesting birds and so that was a another same similar source code slightly adapted but hopefully they could have a common base and then just a different style sheet on top where you know just minor differences right and so this 1 actually the yeah you could see how you could specify an environment variable here but yeah that's what it takes too long to build than it fails on on open we need to clean up build process to run a little bit quicker or or allow for longer and longer build times but at least when you're doing your app create state if I do this in 2 steps where I created a JS for a really act as host grass and then add the code it works just fine but this 1 liner is where it gets really powerful and so if you're doing really advanced DB services like let's say you have a local development machine and you
want talk to your remote PostgreSQL here I'm back in my local development I could run RHC port forward and that will make some local connections to my remote DB available but also my remote server so I could go here amounts they can go here and load up this
URL and it will
proxy through to my remote environment
same thing with the pose recipe of PG admin or something locally but there's there's your URL but you can also have a blog post on how to use local
developments and develop against your remote OpenShift servers so if you're on a locked down laptops we're not allowed to install PostgreSQL stand up and OpenShift environment said at the port forward but you're done right so and so yeah good good stuff there as well
we also have a post on how to connect to existing post gressor offices from an open shift from and so if you had a big inter you know your own PG database that's large and you could talk to your own PG database instead of the small OpenShift ones were kind spending up a separate single PG for each development environments and if you want to talk to a central you know PostgreSQL master 1 your slaves you know you you hit that that 2nd link there will have more information on how to get that done and so automating your DB set up some these there's still some remaining work here we've got just about everything done but we haven't able post GAS women created a table schema and we haven't added our Geospatial index we haven't injected our data into our application and was take a look at how that stuff might work and so
here I have found that there's a dot OpenShift folder where will allow you to define and some action books and action hopes are basically just scripts this 1 is a batch script and if it's a Ruby script that's fine we just try to run the script if it's defined and we have a couple different scripts this 1 is called wallet so this gets run on every deploy there's also a 1 called building pre-build post build United depending on what you want a automate you can hook into several different parts of the process and run arbitrary scripts to help set up your database I actually relocated all the code into something that's actually run via my packaged . J didn't want my code be so really specific to OpenShift I wanted anyone to be able to initialize the DB even if they were OpenShift user so let's jump back to the package that Jason and see where that in thing is defined what file all of our data there could so here you can see in scripts instead of just the start script and a couple other ones is build there's flush DB in the DB and so there's a couple different things and this just runs in the in run in the OK which runs in the in the stress so it's could take a look at uh then bootstrap have some of that
code here in the slides so here are similar to what we saw before were relying on the configured to not refer to anything about how to log into our database were using tg query for super clean easy queries and here I am finding the the remote connection strength from figure in the table name and I make my db connection here and I'm going to grab all of our R points that's energies on file and start loading these into the deep in the database so the 1st function we call is in the DB and in DB basically just adds the post GIS extension and then runs this callback afterwards create DB schema so these basically chained together no j ust does everything asynchronously so if you wanna run things in order use callbacks like that so here we're creating the DB schema next and here it checked for errors and then goes and runs as create table it creates all the table schema here some and finally we end up adding spatial index here and then importing are mapped points see a thing they do a small amount of translation and yeah I did some kind that translation there was a quote marks in the file that was breaking the query structure so I did a little search and replace them with double quotes around the single quote uh assuming command tweak need to make with our input data so that's it we've got we've got results for node j here the resulting application of and if you guys want to give that a try 1st for Python flask you can get a flask dashed those GIS these are all the fully completed apps with everything I've been talking about and we also have a job of hibernate solution and enough that 1 works as an instant after all show you real quick and were pretty much at a time and but here is what it would look like here's any kind of AP creation for OpenShift the typing RHC at create the name the act however many cartridge dependencies you need it also specify your source code and so specifically here we can run something like this in
order to spin up a new call this approach for maybe an hour how many of these parks
that have got a lot of his alive demo of the completed
results so here are mapped point set on Boston when I drag out we some more points added as I pan over any time I panda zoom it's redrawing all the points with a limit of 40 right pretty fast time and the the parks data is just national parks and historic sites that click on any of these patterns and see what any of these points are I also added for many of you guys have seen a clone me on get out banners and I'm a fan of economy and get have kind a reverse that people have been modified it but those running the on OpenShift right so with this click this goes right into our web based workflow for creating apps so here I could create parks 5 here's my get source I could say hey I need extra memory give me a larger size environment already has Python and PostgreSQL listed as my dependencies all this stuff was just encoded in the link here in the URL so yet create application turned scaling on and off the that's 1 you know 2 clicks click on the ribbon click on create if they already have an open account and you can host around OpenShift so that really really cool
stuff there with without web-based workflow for
creating apps have a post on how to customize the workflow and construct URL strings so whether you like the ribbon or not if you wanna give someone a link to launch myapp look up that post and we've got info on how you can know how you can really compose these apps based on source code and was to Karger's dependencies and here's a post on how to make those rhythms and algorithms to your app tuning PostScript amount time around like 2 minutes over if you guys are OK with that alright this is some of the good stuff here where the heck did my G H not comfortable and we're supposed rescue will not come as a developer I don't usually like are theories developer shouldn't have to mess with this stuff they should be step that the operations team and the developers are collaborating on a conversation about how we scale and do we scale horizontally in small chunks at a time or we scale and larger chunks of time but either way we should have a focus on horizontal scaling and redundancy right so let's let's get the developers out of these files give them easy on-demand environments and ops team can tune the PostgreSQL Partridge developers can also to meet the bit we have some environment variables set posts OpenShift PostgreSQL you will shared buffers allows you to set the number of shared buffers yields a set the number of Macs connections Israel's citable just with that RHC the set for us for setting environment variables and then I'll go into affects you may need to reload your database to to pick those up but you know pretty easy and a lot of the stuff you see in this wiki page on tuning oppose press server is pretty easily doable on on OpenShift and other advanced configuration so here's 1 issue I was talking with the guys from crunchy data views heard of anyone familiar with crunchy data will check this out these guys give me a warning that they had some issues with the PostgreSQL 9 2 cartridge with the statistics collector and I don't know if this was like after a million records or after a after a certain amount it's a scale that I haven't hit yet with my tiny little demo apps but they say after a certain number of iterations that is statistics collector was a little bit body in all our PostgreSQL 19 cartridge so what they do they that they created their own PostgreSQL 9 3 cartridge for OpenShift and this is
something that you can run right
away from you know I did that RHC cartridge add you could specify the URL of this and add PostgreSQL 9 3 even we don't support it we don't we don't we will answer the phone calls and and when you say hey post press 9 3 is busted really a we don't it's not in our list of supported stuff but you can opt into running arbitrary cartridges from did have and so that's
definitely something good to look at this post Grassmann 3 court from
crunchy data also they have a 9 4 develop with the RLS patch available and if you wanted to do highly-available PostgreSQL and on open Shinya enterprise environments and they got solutions for that as well so they just had a big and kind of launch announcements and they'll do load balancing geographic failover master-slave replication and and other
things but yeah there's a link to this post if you want information on bringing all this technology in house
into your own data set
and I think that's about it we accept pull requests we want help with everything we use Pepys for a major that'll pipeline uses its own project enhancement proposal we use that for a major feature enhancements you could track all of our the everything we use public everything we use open-source just check us out online and you could see what we're up to we also have this a third-party index for and here's where you
can find your origin we . com you can add your own cartridge solutions or find other third-party cartridges that people like crunchy data are building so there's a link to those cartridges
and was effected wrap
this up over we got some really cool stuff a darker coming up in the future keep an eye on on shift in our doctor support OpenShift Origin is our upstream like I said line 3 apps everyone can run that and that's about it if anyone clicked on that on that
ribbon at the in the in the mapping after they have said they are be alive with their own mapping solution click there and you could be alive with your now array I think that's it for
me thank so thanks for sticking