Welcome ======= This bundle provides you with a fully functional Swarm deployment to get started with modding Swarm with a minimal amount of effort. One quick 'vagrant up' will create your own Swarm instance with a data laden Perforce server to start playing with. Requirements ------------ To use this bundle you will need to download and install the following tools, both of which are free. * VirtualBox (https://www.virtualbox.org/) * Vagrant (http://vagrantup.com) If you're not familiar with Vagrant it is a command line based virtual machine management tool that makes it easy to create and provision virtual machines, all driven by a simple text file. If you haven't used it before be warned; simple VM management is addictive. VirtualBox is an open source hypervisor made by Oracle. It runs on many platforms and is the default hypervisor for Vagrant. You do not need to know much of anything about Vagrant to use these tools. We'll explain the few commands you will likely need below. Given that you are using a virtual machine you will need at least 512MB of RAM to run the Swarm environment. You will also need at least a gig of drive space to hold the VM image. Usage ----- 1) Grab the swarm_env.tgz file from http://swarm.public.perforce.com 2) Untar it into a directory of your choosing 3) Grab the latest build of Swarm from ftp.perforce.com and untar into the same directory 4) From a command prompt, cd to the directory that you originally created 5) Move the contents of swarm- directory into the current directory. ex: mv swarm-2013.1-123456/* . 6) From the command prompt run 'vagrant up'. The command 'vagrant up' tells Vagrant to look for the cleverly named 'Vagrantfile' and create the VM describe within. It will automatically download the required VM base image (Ubuntu 12.04 64-bit) and spin up a new VM. This base image download only occurs once. It will then execute the included Puppet scripts to deploy Swarm and p4d. Note you will need an internet connection during this process; it needs to fetch the p4 and p4d binaries from our site. Once Vagrant returns you will have a fully functional Swarm and Perforce installation. Vagrant will forward Swarm to port 8080 on your machine and will forward Perforce to port 1666. From the command line you should be be able to run 'p4 -p 1666 info' and from the browser you should be able to go to "http://localhost:8080" and see your Swarm installation. Note that right after the VM finishes creating the Swarm instance you may see the Swarm activity feed changing. This is normal and reflects that the new Swarm installtion is busily generating the activity feed from past history. Vagrant Basics -------------- You will need very few commands to be successful with Vagrant for this project. Here are the commands you will need. * vagrant up - creates and provisions a new virtual machine if one does not currently exist * vagrant destroy - halts and deletes the current virtual machine * vagrant ssh - ssh's you into the VM so you can work on the machine That's it! With those three commands you should be suitably dangerous to develop against Swarm successfully. One important part of using Vagrant is taking advantage of the shared folders it creates. With this project we automatically link most of the files that are in the directory along with the Vagrantfile to appropriate places within the VM. For instance, the 'public' folder that came from the Swarm tarfile is linked in the VM to '/var/www/swarm/public'. By default all files and directories that are in the directory with the Vagrantfile are also shared to '/vagrant' on the guest VM. These shared folders allow you to use your favorite editors on your computer with the files that are being used by the VM. Without SSHing in you can edit files live inside the VM. This is one of the biggest advantages of using Vagrant; it lets you code with your preferred tools while still having the controlled environment your app needs. This also means that if at any point you need a clean test environment a quick 'vagrant destroy' and 'vagrant up' will give you a fresh installation with all of your code changes intact. 'vagrant destroy' only deletes the contents of the VM, not the contents of your host machine. ### Note ### This Swarm project is setup to preserve the Perforce server even when 'vagrant destroy' is called. If you want an entirely clean environment make sure to delete the 'perforce' directory that gets created in the same directory as the Vagrantfile. Workflow -------- Here's a very generic example of how everything above comes together to allow you to modify Swarm. 1) Run the setup above. Once complete you have a fully functional Swarm installation. 2) Begin adding your code. If you are working in PHP your code will go in the 'modules' directory. If you are working with 'CSS/js' you will add your code to 'public/custom'. 3) Test and code as needs be using your normal editor, browser, and Perforce client. 4) ... 5) Profit! ### Note ### If you are working in PHP you will need to restart Apache to have it pick up your changes. This is not necessary when working with CSS/js; a simple page refresh will suffice. To do this: 1) Run 'vagrant ssh' from the directory you created to shell into the VM. 2) Run 'sudo service apache2 restart' to restart Apache and pick up your changes. Versioning Recommendations -------------------------- To properly version your work make sure to add all of the contents of the swarm_env.tgz(Vagranfile and manifest directory) to source control as well as your code. That will make it easy to drop in different versions of Swarm as needs be. Help?!??! --------- If you need help or have comments or concerns swing by the Perforce forums at http://forums.perforce.com and post in the Swarm list. The Swarm and Community Development teams are very active there and will help you out in anyway possible.