diff --git a/roles/phabricator/tasks/daemons.yml b/roles/phabricator/tasks/daemons.yml index 339d7e6..081d0e8 100644 --- a/roles/phabricator/tasks/daemons.yml +++ b/roles/phabricator/tasks/daemons.yml @@ -1,17 +1,39 @@ --- + +# Service + - name: PHD systemd service for phabricator template: src: "{{ phd_init }}" dest: /usr/lib/systemd/system/phd.service mode: 0644 notify: reload systemctl - name: Start PHD service: name=phd state=started enabled=true +# Specialized daemons + +- name: Start Pull daemons for a group of repositories + template: + src: "{{ phd_pull }}" + dest: /opt/pull-daemons.sh + owner: "{{ phd_user }}" + group: "{{ phd_user }}" + mode: 0750 + +- name: Restart daemons for new repositories in cron + cron: + name: Restart daemons so new repo are picked up + hour: 6 + minute: 0 + job: systemctl restart phd + +# System + - name: Configure OOM for php cron: name: Preferably kill php in OOM condition hour: 0 job: for p in $(/usr/bin/pgrep php); do /bin/echo 10 > /proc/$p/oom_adj; done diff --git a/roles/phabricator/templates/phd_init b/roles/phabricator/templates/phd_init index 44321ab..6cef0d1 100644 --- a/roles/phabricator/templates/phd_init +++ b/roles/phabricator/templates/phd_init @@ -1,16 +1,17 @@ [Unit] Description=PHD Phabricator After=remote-fs.target [Service] Type=oneshot RemainAfterExit=true -ExecStart={{ phabricator_path }}phabricator/bin/phd start -ExecStart={{ phabricator_path }}phabricator/bin/phd launch 5 pull +ExecStart={{ phabricator_path }}phabricator/bin/phd launch 1 pull +ExecStart={{ phabricator_path }}phabricator/bin/phd launch 1 trigger ExecStart={{ phabricator_path }}phabricator/bin/phd launch 10 task -ExecStop={{ phabricator_path }}phabricator/bin/phd stop --force +ExecStart=/opt/pull-daemons.sh +ExecStop={{ phabricator_path }}phabricator/bin/phd stop --force --gracefull 5 User={{ phd_user }} Group={{ phd_user }} [Install] WantedBy=multi-user.target diff --git a/roles/phabricator/templates/pull-daemons.sh b/roles/phabricator/templates/pull-daemons.sh new file mode 100755 index 0000000..4f13518 --- /dev/null +++ b/roles/phabricator/templates/pull-daemons.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +BIN={{ phabricator_path }}phabricator/bin +NB=4 + +$BIN/repository list > /tmp/repo +lines=$(wc -l /tmp/repo | awk '{print $1}') +split -d -l $(($lines / $NB)) /tmp/repo /tmp/repo_ + +for i in $(ls /tmp/repo_*); do + $BIN/phd launch 1 pull -- $(cat $i | tr '\n' ' ') +done + +rm -f /tmp/repo* + diff --git a/vars/main.yml.example b/vars/main.yml.example index 218f36e..7cfa19d 100644 --- a/vars/main.yml.example +++ b/vars/main.yml.example @@ -1,134 +1,135 @@ --- env: prod project_name: "c4science" ansible_ssh_user: "centos" proxy: no http_proxy: "" https_proxy: "" no_proxy: "localhost" proxy_url: "{{ http_proxy }}" __no_proxy: "{{ no_proxy }}" user_pwd_root: "" user_pwd_centos: "" # OpenStack keypair_name: "" image_id: "" image_id_coreos: "" public_net: "" private_net: "" flavor_id_small: "" flavor_id_medium: "" flavor_id_large: "" flavor_id_small_backup: "" private_net_backup: "" image_id_backup: "" region_main: "" region_back: "" # Storage glusterfs_default_release: 38 s3_access_key: "" s3_secret_key: "" s3_endpoint: "" s3_bucket: "" s3_region: "" # Lbs internal_ip: 0.0.0.0 external_ip: 0.0.0.0 backup_ip: 0.0.0.0 ip_range: "10.0.0.0/16" notif_port: 22280 jenkins_port: 8080 stats_port: 8082 monit_port: 8081 monit_user: admin monit_pass: rolling_reboot_proxy_host: "{{ external_ip }}" rolling_reboot_pause: 30 rolling_reboot_wait_delay: 20 # App developer_mode: false http_scheme: 'http://' domain: example.com file_domain: "example-cdn.com" phabricator_branch: production phabricator_path: /srv/ repositories_path: /var/repo/ files_path: /var/files/ phd_user: phabricator www_user: apache vcs_user: git vcs_port_front: 22 vcs_port_back: 2222 jenkins_prefix: "/" jenkins_url: "{{ http_scheme }}jenkins.{{ domain }}{{ jenkins_prefix }}" jenkins_user: "admin" jenkins_token: "" jenkins_cred: "xxx-yyy-zzz" shib_metadata_file: "metadata.xml" shib_metadata_provider: "http://example.com/{{ shib_metadata_file }}" phabricator_domains: - "{{ domain }}" - 'example.com' google_webmaster_file: "googleXYZ.html" phab_admin_apikey: 'api-xyz' # Dbs mysql_repl_user: "repl" mysql_repl_pass: "" mysql_app_user: "" mysql_app_pass: "" mysql_shib_user: "" mysql_shib_pass: "" mysql_shib_db: "shibboleth" mysql_lbs_user: "haproxy" mysql_cluster_name: "" mysql_host: "10.0.0.0/255.255.0.0" # SSH ssh_keys: - "ssh-rsa mysuperkey1" - "ssh-rsa mysuperkey2" # Swap swap_path: "/swapfile" dd_bs_size_mb: 32 swap_count: 128 swappiness: 10 vfs_cache_pressure: 50 # Email configure_postfix: true enable_postfix_domain_rewrite: true enable_postfix_relayhost: true postfix_relayhost: "[{{ internal_ip }}]" postfix_rewrite_domain: "{{ domain }}" email_alias_phabricator: "" email_alias_postmaster: "" email_alias_admin: "" email_monitoring: "" # Config files php_ini: '../roles/phabricator/templates/php.ini' php_enable: '../roles/phabricator/templates/php.sh' sudoers: '../roles/phabricator/templates/sudoers' ssh_hook: '../roles/phabricator/templates/ssh_hook.sh' sshd_config: '../roles/phabricator/templates/sshd_config' sshd_init: '../roles/phabricator/templates/sshd_init' phd_init: '../roles/phabricator/templates/phd_init' +phd_pull: '../roles/phabricator/templates/pull-daemons.sh' aphlict_init: '../roles/phabricator/templates/aphlict_init' aphlict_conf: '../roles/phabricator/templates/aphlict.custom.json' myconfig: '../roles/phabricator/templates/myconfig.conf.php' cust_phab_update_repo: '../roles/phabricator/templates/phab_update_repo.sh' cust_repo_gc: '../roles/phabricator/templates/repo-gc.sh' cust_compact_storage: '../roles/phabricator/templates/compact-storage.sh' repo_clusterize: '../roles/phabricator/templates/clusterize.py' arcanist_config: '../roles/phabricator/templates/arcrc'