Skip to content

Commit

Permalink
Automatically starting and pulling gameeso server software on boot
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwilli committed Jun 17, 2014
1 parent 4d5f614 commit 93104d7
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 45 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Gameeso can run on several cloud providers out of the box. **More provider-suppo
Replace the <> values by your own api key and client id

6. You are now ready to build! Run: `packer build -var-file=packer_variables.json -only=digitalocean packer.io.json`
7. After a while you have a snapshot named 'Gameeso < random timestap >', which you can use to set up gameeso servers.
7. After a while you have a snapshot named 'Gameeso < random timestamp >', which you can use to set up gameeso servers.
8. After instantiating a snapshot, your server is automatically booted and running at your ip on port: 3000

##Building your image from source (not needed for development)
Expand Down Expand Up @@ -92,7 +92,7 @@ MySQL has a default root password 'gameeso'. **This is not a problem.** All Game

### OMG you **** I want to keep my Mac!! Why using a VM?

**Dont worry!** I too want to keep my tools! While engineering the images, and it's build-platform, I took into account that the VM will **just be the server**, meaning that the sources are exposed to your host-machine. You can edit & commit them with whatever you want!
**Dont worry!** I too want to keep my tools! While building the images I took into account that the VM will **just be the server**, meaning that the sources are exposed to your host-machine. You can edit & commit them with whatever you want!

One thing I've seen at OpenKit is that the curve to run the server is pretty steep. There is nothing wrong with that, but I think it's better if developer can get started quicker and dive faster in the code, not having to worry about anything server-related.

Expand Down
9 changes: 1 addition & 8 deletions cloud_images/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.

# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "UbuntuTrusty"

# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
Expand Down Expand Up @@ -41,7 +34,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
config.vm.synced_folder "gameeso/", "/var/gameeso"
config.vm.synced_folder "gameeso/", "/var/gameeso", :create => "true"

# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
Expand Down
42 changes: 21 additions & 21 deletions cloud_images/packer.io.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
{
"provisioners": [
{
"type": "shell",
"execute_command": "sh '{{.Path}}' {{user `user_password`}}",
"override": {
"digitalocean": {
"scripts": [
"scripts/setup_default_user.sh"
]
},
"virtualbox-iso": {
"scripts": [
"scripts/dummy.sh"
]
},
"vmware-iso": {
"scripts": [
"scripts/dummy.sh"
]
}
}
},
{
"type": "shell",
"execute_command": "echo 'gameeso'|sudo -S sh '{{.Path}}'",
Expand Down Expand Up @@ -57,6 +36,27 @@
]
}
}
},
{
"type": "shell",
"execute_command": "sh '{{.Path}}' {{user `user_password`}}",
"override": {
"digitalocean": {
"scripts": [
"scripts/setup_default_user.sh"
]
},
"virtualbox-iso": {
"scripts": [
"scripts/dummy.sh"
]
},
"vmware-iso": {
"scripts": [
"scripts/dummy.sh"
]
}
}
}
],
"post-processors": [
Expand Down
9 changes: 0 additions & 9 deletions cloud_images/scripts/bundle_install_openkit_server.sh
Original file line number Diff line number Diff line change
@@ -1,9 +0,0 @@
cd /var/gameeso
git clone -b development https://github.com/Gameeso/openkit-server.git
cd openkit-server/dashboard

bundle install --path vendor/bundle
bundle update
bundle exec bin/rake db:setup RAILS_ENV=development

start gameeso
32 changes: 27 additions & 5 deletions cloud_images/scripts/install_openkit_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,42 @@ mkdir -p /var/gameeso
chmod 7777 -R /var/gameeso

cat >/usr/bin/start_gameeso <<EOL
mkdir -p /var/gameeso
chmod 7777 -R /var/gameeso
cd /var/gameeso
if [ ! -d "openkit-server" ]; then
# Vagrant tends to delete contents of a synced folder once it's trying to set up synced folders.
# By waiting for 10 seconds we avoid to become deleted right in the middle.
sleep 10
echo "Cloning & installing latest Gameeso server development branch"
git clone -b development https://github.com/Gameeso/openkit-server.git
cd openkit-server/dashboard
bundle install --path vendor/bundle
bundle update
bundle exec bin/rake db:setup RAILS_ENV=development
fi
cd /var/gameeso/openkit-server/dashboard
bin/rails server
EOL

chmod a+x /usr/bin/start_gameeso

cat >/etc/init/gameeso.conf <<EOL
description "Gameeso Game Backend"
start on filesystem or runlevel [2345]
stop on run level [!2345]
exec /usr/bin/start_gameeso
start on (local-filesystems and net-device-up IFACE!=lo)
stop on shutdown
script
exec /usr/bin/start_gameeso
end script
EOL

# Firewall
Expand Down

0 comments on commit 93104d7

Please sign in to comment.