Created
June 1, 2015 09:08
-
-
Save benley/52cd48a5774fac423fd9 to your computer and use it in GitHub Desktop.
Hydra on aurora
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include('lib/nix.aurora') | |
include('lib/structs.aurora') | |
include('hydra.secrets') | |
class Logo(Struct): | |
url = Required(String) | |
filetype = Default(String, 'png') | |
GRAVATAR = Logo( | |
url = "https://secure.gravatar.com/avatar/13ddbf022b98acb2e32dbe8d72b81b22.jpg", | |
filetype = "jpg") | |
proc_hydrainit = Process( | |
name = 'hydrainit', | |
cmdline = unindent( | |
r""" | |
set -x -e | |
cat >> .thermos_profile <<'EOF' | |
export HYDRA_DBI="dbi:Pg:dbname={{db.db}};host={{db.host}};user={{db.user}};password={{db.password}}" | |
export HYDRA_DATA="$HOME/hydra" | |
export HYDRA_CONFIG="$HOME/hydra/hydra.conf" | |
EOF | |
nix-channel --add http://hydra.nixos.org/jobset/hydra/master/channel/latest hydra | |
nix-channel --update | |
nix-env -i curl hydra --option extra-binary-caches https://hydra.nixos.org | |
mkdir -p hydra | |
cat > hydra/hydra.conf <<EOF | |
enable_persona 1 | |
persona_allowed_domains folsomlabs.com | |
using_frontend_proxy 1 | |
base_uri https://hydra.corp.folsomlabs.com | |
EOF | |
curl '{{logo.url}}' > 'hydra_logo.{{logo.filetype}}' \ | |
&& echo "hydra_logo $PWD/hydra_logo.{{logo.filetype}}" >> hydra/hydra.conf | |
. .thermos_profile | |
hydra-init | |
""")) | |
# Things that can go in hydra.conf: | |
# | |
# hydra_logo pathtofile.png | |
# binary_cache_private_key_file | |
# binary_cache_key_name keyname | |
# persona_allowed_domains | |
# private (1|0) | |
# enable_persona (1|0) | |
# using_frontend_proxy (1|0) | |
# base_uri http://... | |
# notification_sender | |
# max_servers | |
proc_hydra = Process( | |
name = 'hydra-server', | |
daemon = True, | |
cmdline = "hydra-server -p {{thermos.ports[http]}}") | |
proc_hydra_evaluator = Process( | |
name = 'hydra-evaluator', | |
daemon = True, | |
cmdline = "hydra-evaluator hydra-evaluator") | |
proc_hydra_queue_runner = Process( | |
name = 'hydra-queue-runner', | |
daemon = True, | |
cmdline = unindent( | |
r""" | |
set +x +e | |
hydra-queue-runner --unlock | |
hydra-queue-runner hydra-queue-runner | |
""")) | |
task_hydra = Task( | |
name = 'hydra', | |
resources = Resources(ram = 2.5*GB, disk = 1*GB, cpu = 0.8), | |
processes = [proc_nixinit, proc_hydrainit, | |
proc_hydra, proc_hydra_evaluator, proc_hydra_queue_runner, | |
proc_nixcleanup], | |
constraints = (order(proc_nixinit, proc_hydrainit) + | |
order(proc_hydrainit, proc_hydra) + | |
order(proc_hydrainit, proc_hydra_evaluator) + | |
order(proc_hydrainit, proc_hydra_queue_runner)) | |
).bind(nix_channel = '') | |
JobWithProfile = Job(contact = '{{jobcfg.contact}}', | |
cluster = '{{jobcfg.cluster}}', | |
role = '{{jobcfg.role}}', | |
environment = '{{jobcfg.environment}}') | |
DEV_PROFILE = Job(contact = 'ben', | |
cluster = 'va', | |
role = 'www-data', | |
environment = 'devel') | |
HydraJob = JobWithProfile( | |
service = True, | |
name = 'hydra', | |
task = task_hydra, | |
instances = 1, | |
announce = Announcer(primary_port = 'http')) | |
jobs = [ HydraJob.bind(db = RDS_HYDRA, jobcfg = DEV_PROFILE, logo = GRAVATAR) ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment