Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Add HHVM image #51

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
9bcf909
Add Nginx+HHVM platform
kinosang Nov 20, 2014
8833e63
Update Dockerfile
kinosang Nov 20, 2014
7a9e85c
Fix HHVM image
kinosang Nov 20, 2014
9f5a245
Update deploy
kinosang Nov 20, 2014
f701dba
Update setup
kinosang Nov 20, 2014
7d0087d
Update start script
kinosang Nov 20, 2014
917591a
Revert "Update start script"
kinosang Nov 20, 2014
8563b09
Update circus.ini
kinosang Nov 20, 2014
cb82197
Create nginx.conf
kinosang Nov 20, 2014
455c60c
Update setup
kinosang Nov 20, 2014
6d4ddfa
Update setup
kinosang Nov 20, 2014
076bfcd
Update start script
kinosang Nov 20, 2014
68afb6e
Update start script
kinosang Nov 20, 2014
4138d31
Updata install
kinosang Nov 20, 2014
ca573d0
Updata install
kinosang Nov 20, 2014
5da1095
Update start script
kinosang Nov 20, 2014
597f227
Change listen port
kinosang Nov 20, 2014
f6c8346
Start HHVM before Nginx
kinosang Nov 20, 2014
cdaef06
Daemon off for nginx
kinosang Nov 20, 2014
fe049d1
Update setup
kinosang Nov 20, 2014
797cc47
Update start
kinosang Nov 20, 2014
87ea9c5
Fix some bugs like nginx doesn't startup automatically
kinosang Nov 21, 2014
162166e
Update startup script
kinosang Nov 21, 2014
11bec49
Update deploy
kinosang Nov 21, 2014
5f66a5b
Update nginx.conf and add custom-nginx-rewrite-rules support
kinosang Nov 21, 2014
640e3b2
For test
kinosang Nov 21, 2014
0c73394
Use HHVM's build-in web-server
kinosang Nov 21, 2014
5adf923
listen on *:8888
kinosang Nov 21, 2014
8f7a836
For test
kinosang Nov 21, 2014
80d1a55
Change to Apache2
kinosang Nov 21, 2014
2477aaf
Fix
kinosang Nov 21, 2014
a5f4363
Update start script
kinosang Nov 21, 2014
8fb0df5
Fix mistakes
kinosang Nov 24, 2014
9431b0c
Use Nginx and circus
kinosang Nov 27, 2014
92585fc
Include hhvm.conf in nginx.conf
kinosang Nov 27, 2014
393e72e
Optimize HHVM's php.ini
kinosang Nov 27, 2014
1797b5d
Disable epoll
kinosang Nov 27, 2014
9b5e879
Update circus.ini
kinosang Nov 27, 2014
0364f99
Add PHP53 Platform
kinosang Nov 27, 2014
5900407
Update install script
kinosang Nov 27, 2014
f5fac65
remove sudo
kinosang Nov 27, 2014
e416db6
remove sudo
kinosang Nov 27, 2014
4cb4f66
Fix some mistakes
kinosang Nov 27, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions hhvm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# this file describes how to build tsuru hhvm image
# to run it:
# 1 - tsuru-admin platform-add hhvm -d https://raw.github.com/tsuru/basebuilder/master/hhvm/Dockerfile

from ubuntu:14.04
run apt-get update
run apt-get install wget -y --force-yes
run wget http://github.com/7IN0-labs/basebuilder/tarball/master -O basebuilder.tar.gz --no-check-certificate
run mkdir /var/lib/tsuru
run tar -xvf basebuilder.tar.gz -C /var/lib/tsuru --strip 1
run cp /var/lib/tsuru/hhvm/deploy /var/lib/tsuru
run cp /var/lib/tsuru/base/start /var/lib/tsuru
run /var/lib/tsuru/hhvm/install
5 changes: 5 additions & 0 deletions hhvm/deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash -el

SOURCE_DIR=/var/lib/tsuru
source ${SOURCE_DIR}/base/deploy
${VENV_DIR}/bin/python ${SOURCE_DIR}/hooks.py
26 changes: 26 additions & 0 deletions hhvm/etc/circus.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[circus]
check_delay = 5
debug = False
endpoint = tcp://127.0.0.1:5555
pubsub_endpoint = tcp://127.0.0.1:5556

[plugin:status_reporter]
use = tsuru.plugins.StatusReporter
loop_rate = 40

[watcher:nginx]
cmd = /usr/sbin/nginx
args = -g "daemon off;"
copy_env = True
stdout_stream.class = tsuru.stream.Stream
stderr_stream.class = tsuru.stream.Stream

[watcher:hhvm]
cmd = /usr/bin/hhvm
args = --config /etc/hhvm/php.ini --config /etc/hhvm/server.ini --mode daemon -vPidFile=/var/run/hhvm/pid
copy_env = True
stdout_stream.class = tsuru.stream.Stream
stderr_stream.class = tsuru.stream.Stream

[plugin:statsd]
use = tsuru.plugins.statsd.Stats
25 changes: 25 additions & 0 deletions hhvm/etc/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
user www-data;
worker_processes 4;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

sendfile on;

keepalive_timeout 65;

server {
listen 8888;
server_name localhost;

root /home/application/current;
index index.html index.htm index.php;

include hhvm.conf;
}
}
16 changes: 16 additions & 0 deletions hhvm/etc/php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
; php options
session.save_handler = files
session.save_path = /var/lib/php5
session.gc_maxlifetime = 1440

max_execution_time = 300
max_input_time = 60
memory_limit = 128M
post_max_size = 12M
upload_max_filesize = 12M

; hhvm specific
hhvm.log.level = Warning
hhvm.log.always_log_unhandled_exceptions = true
hhvm.log.runtime_error_reporting_level = 8191
hhvm.mysql.typed_results = false
12 changes: 12 additions & 0 deletions hhvm/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash -e

SOURCE_DIR=/var/lib/tsuru
$SOURCE_DIR/base/install
wget -O - http://dl.hiphop-php.com/conf/hhvm.gpg.key | sudo apt-key add -
echo deb http://dl.hiphop-php.com/ubuntu trusty main | sudo tee /etc/apt/sources.list.d/hhvm.list
sudo apt-get update
apt-get install nginx hhvm -y
cp ${SOURCE_DIR}/hhvm/etc/circus.ini /etc/circus/circus.ini
cp ${SOURCE_DIR}/hhvm/etc/nginx.conf /etc/nginx/nginx.conf
cp ${SOURCE_DIR}/hhvm/etc/php.ini /etc/hhvm/php.ini
/usr/share/hhvm/install_fastcgi.sh
18 changes: 18 additions & 0 deletions php53/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# this file describes how to build tsuru php53 image
# to run it:
# 1- install docker
# 2- run: $ docker build -no-cache -t tsuru/php53 https://github.com/7IN0-labs/basebuilder/master/php53/Dockerfile

from ubuntu:12.04
run apt-get update
run apt-get install wget -y --force-yes
run mkdir /var/lib/tsuru
run wget --no-check-certificate https://github.com/7IN0-labs/basebuilder/tarball/master -O basebuilder.tar.gz
run tar -xvf basebuilder.tar.gz -C /var/lib/tsuru --strip 1
run rm basebuilder.tar.gz
run rm /var/lib/tsuru/so_dependencies
run cp /var/lib/tsuru/php53/so_dependencies /var/lib/tsuru
run cp /var/lib/tsuru/php53/deploy /var/lib/tsuru
run cp /var/lib/tsuru/php53/start /var/lib/tsuru
run /var/lib/tsuru/php53/install
run /var/lib/tsuru/php53/setup
52 changes: 52 additions & 0 deletions php53/apache_modules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import os

import yaml


def load_modules(data):
result = yaml.load(data)
if result:
apache = result.get('apache', {})
if apache:
return apache.get('modules', [])
return []


def install_modules(modules):
installed = 0
for module in modules:
print " Installing Apache module %s" % module
os.system("a2enmod "+module+" >/dev/null 2>&1")
installed = installed + 1

if installed > 0:
os.system('/etc/init.d/apache2 restart >/dev/null 2>&1')
print " Done enabling Apache modules."
else:
print " No Apache modules to enable."


def load_file(working_dir="/home/application/current"):
files_name = ["app.yaml", "app.yml"]
for file_name in files_name:
try:
with open(os.path.join(working_dir, file_name)) as f:
return f.read()
except IOError:
pass
return ""


def main():
print ""
print ""
print ""
print "========================================"
print " Parsing Apache modules to enable"
print "========================================"
print ""
data = load_file()
modules = load_modules(data)
install_modules(modules)

main()
34 changes: 34 additions & 0 deletions php53/deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash -el

echo "Deploying on platform PHP 5.3"

APP_DIR=/home/application/current
SOURCE_DIR=/var/lib/tsuru
source ${SOURCE_DIR}/base/deploy

${VENV_DIR}/bin/python ${SOURCE_DIR}/hooks.py

${VENV_DIR}/bin/python ${SOURCE_DIR}/php53/apache_modules.py


echo ""
echo ""
echo ""
echo "========================================"
echo " Parsing Composer dependances..."
echo "========================================"
echo ""
# check for Composer dependencies and vendors are not bundled in the pack
if [ -f ${APP_DIR}/composer.json ] && [ ! -d ${APP_DIR}/vendor ]; then
# check if Composer is provided
if [ -f ${APP_DIR}/composer.phar ]; then
echo " Using provided composer..."
else
echo " Downloading composer..."
wget --quiet http://getcomposer.org/composer.phar -O ${APP_DIR}/composer.phar
fi

php ${APP_DIR}/composer.phar install
else
echo " Missing composer.json file or 'vendor' directory exists. Skipping composer..."
fi
24 changes: 24 additions & 0 deletions php53/etc/apache-vhost
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
NameVirtualHost *:8888
Listen 8888

<VirtualHost *:8888>
ServerAdmin webmaster@tsuru

DocumentRoot /home/application/current
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /home/application/current/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
19 changes: 19 additions & 0 deletions php53/etc/circus.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[circus]
check_delay = 5
debug = False
endpoint = tcp://127.0.0.1:5555
pubsub_endpoint = tcp://127.0.0.1:5556

[plugin:status_reporter]
use = tsuru.plugins.StatusReporter
loop_rate = 40

[watcher:apache2]
cmd = /usr/sbin/apache2
args = -d /etc/apache2 -k start -DNO_DETACH
copy_env = True
stdout_stream.class = tsuru.stream.Stream
stderr_stream.class = tsuru.stream.Stream

[plugin:statsd]
use = tsuru.plugins.statsd.Stats
28 changes: 28 additions & 0 deletions php53/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash -e

SOURCE_DIR=/var/lib/tsuru
source ${SOURCE_DIR}/config

mkdir -p /home/application
useradd -m ${USER} -s /bin/bash
chown ${USER}:${USER} /home/application

cat >> /home/ubuntu/.bashrc <<EOF
[ -f /home/application/apprc ] && source /home/application/apprc
EOF

apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install curl git openssh-server python-virtualenv python-pip libzmq-dev g++ python-dev wget libyaml-dev -y

virtualenv ${VENV_DIR}
${VENV_DIR}/bin/pip install circus==0.11.1 tsuru-circus tsuru-unit-agent
pip install tsuru-unit-agent

sed -ri 's/^session\s+required\s+pam_loginuid.so$/session optional pam_loginuid.so/' /etc/pam.d/sshd
mkdir /var/run/sshd
echo "export DEBIAN_FRONTEND=noninteractive" >> /etc/profile

mkdir -p /etc/circus
cp ${SOURCE_DIR}/utils/circus.ini /etc/circus/circus.ini

apt-get install apache2 php5 -y
17 changes: 17 additions & 0 deletions php53/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -el

SOURCE_DIR=/var/lib/tsuru
source ${SOURCE_DIR}/config

mkdir -p /etc/circus
cp ${SOURCE_DIR}/php53/etc/circus.ini /etc/circus/circus.ini
rm /etc/apache2/sites-enabled/*
ln -s ${SOURCE_DIR}/php53/etc/apache-vhost /etc/apache2/sites-enabled/tsuru-vhost.conf
cat >> /etc/profile<<END
export APACHE_RUN_USER=ubuntu
export APACHE_RUN_GROUP=ubuntu
export APACHE_PID_FILE=/var/run/apache2/apache2.pid
export APACHE_RUN_DIR=/var/run/apache2
export APACHE_LOCK_DIR=/var/lock/apache2
export APACHE_LOG_DIR=/var/log/apache2
END
28 changes: 28 additions & 0 deletions php53/so_dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash -el

function so_dependencies() {
export DEBIAN_FRONTEND=noninteractive
if [ -f ${CURRENT_DIR}/repositories.apt ]; then
set +e
apt-get install software-properties-common -y --force-yes
status=$?
set -e
if [ ${status} != 0 ]; then
apt-get update
apt-get install software-properties-common -y --force-yes
fi
for repo in `cat ${CURRENT_DIR}/repositories.apt`; do
add-apt-repository -y ${repo}
done
fi
if [ -f ${CURRENT_DIR}/requirements.apt ]; then
set +e
apt-get install $(cat ${CURRENT_DIR}/requirements.apt) -y --force-yes
status=$?
set -e
if [ ${status} != 0 ]; then
apt-get update
apt-get install $(cat ${CURRENT_DIR}/requirements.apt) -y --force-yes
fi
fi
}
4 changes: 4 additions & 0 deletions php53/start
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash -l

source /var/lib/tsuru/config
${VENV_DIR}/bin/circusd /etc/circus/circus.ini --daemon --log-output /var/log/circus.log