Difference between revisions of "DevelopmentVMHowto"

From SoylentNews
Jump to: navigation, search
(Add more detailed instructions on applying the upgrades file, add info about slash having admin rights)
 
(27 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
[[Development]] - parent
 
[[Development]] - parent
  
The Dev VM can be downloaded from http://torrents.soylentnews.org/.  This is a vim that is designed to run on VirtualBox. Information and downloads of VirtualBox are available here: http://torrents.soylentnews.org/.
+
== Download and Install VM  ==
 +
The Slashdev VM can be downloaded from http://vm.soylentnews.org/Slashdev_14.10.ova.  This is the latest Slashdev VM and has many enhancements over the original version. It is a VM that is designed to run on VirtualBox. Information and downloads of VirtualBox are available here: https://www.virtualbox.org.
  
Once you get the VM downloaded and the VirtualBox up and ruining, you will want to do a '''File:Import Appliance''' in VirtualBox.  This will unpack the VM into you environment. Start up the VM and log in with the username and password of slash.
+
Once you get the VM downloaded and the VirtualBox up and running, you will want to do a '''File:Import Appliance''' in VirtualBox.  This will unpack the VM into you environment. Start up the VM and log in with the username and password of slash.  
  
 
The VM has port forwarding setup to you local system for ssh and http.   
 
The VM has port forwarding setup to you local system for ssh and http.   
  
<blockquote><code>ssh: 8022<br/>
+
<pre>ssh: 8022
http; 1337</code></blockquote>
+
http: 1337</pre>
  
 
For ssh your connection string should be:
 
For ssh your connection string should be:
  
<blockquote><code>ssh slash@127.0.0.1 -p 8022</code></blockquote>
+
<pre>ssh slash@127.0.0.1 -p 8022</pre>
  
For websites, apache will use the name localhost instead of 127.0.0.1 so you will need to use:
+
User slash is in groups sudo and adm, so '''if''' you want to get a root shell you can get it by entering
  
<blockquote><code>http://localhost:1337 </code></blockquote>
+
<pre>sudo bash</pre>
  
Apache is turned off in the VM. You will need to turn it on using the command:
+
Caution: Normally you won't need a root shell here.
  
<blockquote><code>apacheclt start</code></blockquote>
+
For websites, Apache will use the name localhost instead of 127.0.0.1 so you will need to use:
  
 +
<pre>http://localhost:1337</pre>
 +
 +
Check if you can access external servers (will be required if you want to install additional packages or directly checkout from github). E.g.
 +
<pre>ping soylentnews.org</pre>
 +
If the domain name cannot be resolved, you might want to shutdown the VM and add a bridged network adapter in network settings.
 +
 +
==Setup the Environment ==
 
The slash user home directory is in /srv/slashdev/.  The slashcode GitHub repository is located in slashcode. This is where you will make changes to the code you want to test.  The actual slashcode install is located in slash.
 
The slash user home directory is in /srv/slashdev/.  The slashcode GitHub repository is located in slashcode. This is where you will make changes to the code you want to test.  The actual slashcode install is located in slash.
  
The first thing you should probably do is update the repo to the latest version.  cd to slashcode and run git pull.
+
The first thing you should probably do is update the repo to the latest version.   
  
Now we need to install the new code to slash.  Here is a script that will help with that.  Create a new file called deployslash.sh in the slash home directory and give chmod it to 755.
+
<pre>
 +
cd ~/slashcode
 +
git pull
 +
</pre>
  
deployslash.sh
+
There are a couple of scripts set up in the vm that make deploying and reloading Slashcode easy.  The first script is deployslash.sh and the second is reloadslash.sh.  These scripts are in the shash user's home directory.  The deployslash.sh script will cd into the slashcode directory and install the Slashcode to the appropriate locations and then stop the slash daemon, stop and start Apache, clear the memcache, and finally restart the slash daemon. The reloadslash.sh script does the last steps only and is generally needed when updating templates, vars, and other items within the admin interface of the slash site.  Most changes will not take effect right away due to caching. The reload will empty the caches and unload any running Perl scripts from memory.
  
<blockquote><code>#! /bin/sh<br/>
+
== MySQL Updates ==
<br/>
+
We sometimes need to update the Slashdev environment to work with the new Slashcode.  The update files are normally in /srv/slashdev/slashcode/sql/mysql/upgrades.  The upgrades file has the latest updates since that last major version of slashcode.  The 14.10 version of the VM is fully up-to-date with with the 14.10 release of Slashcode, so no updates to MySQL are currently needed.  You will need to add any future DB updates that are listed in the upgrades file to keep the new code working properly.
echo === Install from git repo ===<br/>
 
echo<br/>
 
cd /srv/slashdev/slashcode<br/>
 
make USER=slash GROUP=slash SLASH_PREFIX=/srv/slashdev/slash install<br/>
 
<br/>
 
echo<br/>
 
echo<br/>
 
echo === Clean up CSS and install Templates ==<br/>
 
echo<br/>
 
rm -rf /srv/slashdev/slash/site/slashdev/htdocs/*css<br/>
 
<br/>
 
/srv/slashdev/slash/bin/symlink-tool -U<br/>
 
/srv/slashdev/slash/bin/template-tool -U<br/>
 
<br/>
 
echo<br/>
 
echo<br/>
 
echo === Restart Apache==<br/>
 
echo<br/>
 
/srv/slashdev/apache/bin/apachectl restart<br/>
 
</code></blockquote>
 
  
This script will be part of the next version of the Dev VM.
+
MySQL is accessed with root as the user and the database slashdev. To access the DB use the command:
 +
<pre>mysql -u root slashdev</pre>
  
 +
On the mysql prompt, to apply the upgrades file, enter
 +
<pre>mysql&gt; source slashcode/sql/mysql/upgrades</pre>
 +
== Update Slash ==
 +
Now lets update slash to our new code by running:
 +
<pre>deployslash.sh</pre>
 +
 +
== Making Your Own Changes ==
 
To do simple updates, you would make changes to the files in slashcode and redeploy using the deployslash.sh script.
 
To do simple updates, you would make changes to the files in slashcode and redeploy using the deployslash.sh script.
  
What if you want to develop code and have it merged into the main repo?  In this case you will need to setup your own copy of the repo do do your development work.  First if you do not have your own account on GitHub please set one up. Next go to the slashcode site https://github.com/SoylentNews/slashcode and click on Fork in the upper right.  Fork the repo to your user account.
+
What if you want to develop code and have it merged into the main repo?  In this case you will need to setup your own copy of the repo do do your development work.  First if you do not have your own account on GitHub please set one up. Next go to the Slashcode site https://github.com/SoylentNews/slashcode and click on Fork in the upper right.  Fork the repo to your user account.
  
 
Now on the VM go to slashcode.  We will setup your copy of the repo as a remote.  Run the commands:
 
Now on the VM go to slashcode.  We will setup your copy of the repo as a remote.  Run the commands:
  
<blockquote><code> git remote add {name} {url-to-your-GitHub-repo}<br/>
+
<pre>
get fetch {name}<br/>
+
git remote add {name} {url-to-your-GitHub-repo}
checkout {name}/master</code></blockquote><br/>
+
git fetch {name}
 +
git checkout {name}/master</pre>
  
 
Redeploy slash and you are working from your own repo.  As you may have noticed the primary work is being done on the master branch.  You will not need to worry about the other branches of the code for now.
 
Redeploy slash and you are working from your own repo.  As you may have noticed the primary work is being done on the master branch.  You will not need to worry about the other branches of the code for now.
  
Once you get code you like, and have it committed to your personal fork, you can do a Pull Request, https://help.github.com/articles/using-pull-requests, that will create a ticket for the SoylentNews/slashcode repo to merge your commits to the master branch.  After proper testing by the Dev team and other sanity checks, you code will be merged and eventually put on to the production servers.  
+
Once you get code you like, and have it committed to your personal fork, you can do a Pull Request, https://help.github.com/articles/using-pull-requests, that will create a ticket for the SoylentNews/slashcode repo to merge your commits to the master branch.  After proper testing by the Dev team and other sanity checks, you code will be merged and eventually put on to the production servers. See [[GitUse]] for more info about using git.
  
 +
Just a note: I am new to git, so the above directions are what I have been using.  If people have a better method for doing this please feel free to update this page with the new information --pauulej72.
  
Just a note: I am new to git, so the above directions are what I have been using.  If people have a better method for doing this please feel free to update this page with the new information --pauulej72.
+
[[Category:Development]]

Latest revision as of 22:16, 18 February 2016

Development - parent

Download and Install VM

The Slashdev VM can be downloaded from http://vm.soylentnews.org/Slashdev_14.10.ova. This is the latest Slashdev VM and has many enhancements over the original version. It is a VM that is designed to run on VirtualBox. Information and downloads of VirtualBox are available here: https://www.virtualbox.org.

Once you get the VM downloaded and the VirtualBox up and running, you will want to do a File:Import Appliance in VirtualBox. This will unpack the VM into you environment. Start up the VM and log in with the username and password of slash.

The VM has port forwarding setup to you local system for ssh and http.

ssh: 8022
http: 1337

For ssh your connection string should be:

ssh slash@127.0.0.1 -p 8022

User slash is in groups sudo and adm, so if you want to get a root shell you can get it by entering

sudo bash

Caution: Normally you won't need a root shell here.

For websites, Apache will use the name localhost instead of 127.0.0.1 so you will need to use:

http://localhost:1337

Check if you can access external servers (will be required if you want to install additional packages or directly checkout from github). E.g.

ping soylentnews.org

If the domain name cannot be resolved, you might want to shutdown the VM and add a bridged network adapter in network settings.

Setup the Environment

The slash user home directory is in /srv/slashdev/. The slashcode GitHub repository is located in slashcode. This is where you will make changes to the code you want to test. The actual slashcode install is located in slash.

The first thing you should probably do is update the repo to the latest version.

cd ~/slashcode
git pull

There are a couple of scripts set up in the vm that make deploying and reloading Slashcode easy. The first script is deployslash.sh and the second is reloadslash.sh. These scripts are in the shash user's home directory. The deployslash.sh script will cd into the slashcode directory and install the Slashcode to the appropriate locations and then stop the slash daemon, stop and start Apache, clear the memcache, and finally restart the slash daemon. The reloadslash.sh script does the last steps only and is generally needed when updating templates, vars, and other items within the admin interface of the slash site. Most changes will not take effect right away due to caching. The reload will empty the caches and unload any running Perl scripts from memory.

MySQL Updates

We sometimes need to update the Slashdev environment to work with the new Slashcode. The update files are normally in /srv/slashdev/slashcode/sql/mysql/upgrades. The upgrades file has the latest updates since that last major version of slashcode. The 14.10 version of the VM is fully up-to-date with with the 14.10 release of Slashcode, so no updates to MySQL are currently needed. You will need to add any future DB updates that are listed in the upgrades file to keep the new code working properly.

MySQL is accessed with root as the user and the database slashdev. To access the DB use the command:

mysql -u root slashdev

On the mysql prompt, to apply the upgrades file, enter

mysql> source slashcode/sql/mysql/upgrades

Update Slash

Now lets update slash to our new code by running:

deployslash.sh

Making Your Own Changes

To do simple updates, you would make changes to the files in slashcode and redeploy using the deployslash.sh script.

What if you want to develop code and have it merged into the main repo? In this case you will need to setup your own copy of the repo do do your development work. First if you do not have your own account on GitHub please set one up. Next go to the Slashcode site https://github.com/SoylentNews/slashcode and click on Fork in the upper right. Fork the repo to your user account.

Now on the VM go to slashcode. We will setup your copy of the repo as a remote. Run the commands:

git remote add {name} {url-to-your-GitHub-repo}
git fetch {name}
git checkout {name}/master

Redeploy slash and you are working from your own repo. As you may have noticed the primary work is being done on the master branch. You will not need to worry about the other branches of the code for now.

Once you get code you like, and have it committed to your personal fork, you can do a Pull Request, https://help.github.com/articles/using-pull-requests, that will create a ticket for the SoylentNews/slashcode repo to merge your commits to the master branch. After proper testing by the Dev team and other sanity checks, you code will be merged and eventually put on to the production servers. See GitUse for more info about using git.

Just a note: I am new to git, so the above directions are what I have been using. If people have a better method for doing this please feel free to update this page with the new information --pauulej72.