forked from Gluejar/regluit
-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Local Development with Vagrant and Ansible #68
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
# All Vagrant configuration is done below. The "2" in Vagrant.configure | ||
# configures the configuration version (we support older styles for | ||
# backwards compatibility). Please don't change it unless you know what | ||
# you're doing. | ||
Vagrant.configure("2") do |config| | ||
# The most common configuration options are documented and commented below. | ||
# For a complete reference, please see the online documentation at | ||
# https://docs.vagrantup.com. | ||
# Every Vagrant development environment requires a box. You can search for | ||
# boxes at https://vagrantcloud.com/search. | ||
config.vm.box = "ubuntu/xenial64" | ||
|
||
# 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. | ||
config.vm.box_check_update = false | ||
|
||
# Setup specific for local machine | ||
config.vm.define "regluit-local", primary: true do |local| | ||
# Create a private network | ||
local.vm.network "private_network", type: "dhcp" | ||
local.vm.hostname = "regluit-local" | ||
|
||
# VirtuaLBox provider settings for running locally with Oracle VirtualBox | ||
# --uartmode1 disconnected is necessary to disable serial interface, which | ||
# is known to cause issues with Ubuntu 16 VM's | ||
local.vm.provider "virtualbox" do |vb| | ||
vb.name = "regluit-local" | ||
vb.memory = 1024 | ||
vb.cpus = 2 | ||
vb.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ] | ||
end | ||
|
||
end | ||
|
||
config.vm.synced_folder ".", "/vagrant", disabled: true | ||
config.vm.synced_folder ".", "/opt/regluit" | ||
|
||
config.vm.network "forwarded_port", guest: 8000, host: 8000 | ||
|
||
# Provision node with Ansible running on the Vagrant host | ||
# This requires you have Ansible installed locally | ||
# Vagrant autogenerates an ansible inventory file to use | ||
config.vm.provision "ansible_local" do |ansible| | ||
ansible.playbook = "/opt/regluit/provisioning/setup-regluit.yml" | ||
ansible.provisioning_path = "/opt/regluit" | ||
ansible.verbose = true | ||
ansible.install = true | ||
end | ||
|
||
config.vm.post_up_message = "Successfully created regluit-local VM. Run 'vagrant ssh' to log in and start the development server." | ||
|
||
end |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
project_path: "/opt/regluit" | ||
django_settings_module: "regluit.settings.me" | ||
virtualenv_name: "venv" | ||
|
||
# MySQL | ||
mysql_db_name: "regluit" | ||
mysql_db_user: "regluit" | ||
mysql_db_pass: "password123" | ||
mysql_db_host: "localhost" | ||
mysql_db_port: 3306 | ||
|
||
# Task Broker | ||
broker_transport: "redis" | ||
broker_host: "localhost" | ||
broker_port: 6379 | ||
broker_vhost: "0" | ||
|
||
# Common.py defaults | ||
boxstream_api_key: "012345678901234567890123456789" | ||
boxstream_api_user: "user" | ||
dropbox_key: "012345678901234" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
#!/bin/bash | ||
# ========================================================= | ||
# celerybeat - Starts the Celery periodic task scheduler. | ||
# ========================================================= | ||
# | ||
# :Usage: /etc/init.d/celerybeat {start|stop|force-reload|restart|try-restart|status} | ||
# :Configuration file: /etc/default/celerybeat or /etc/default/celeryd | ||
# | ||
# See http://docs.celeryq.org/en/latest/cookbook/daemonizing.html#init-script-celerybeat | ||
# This file is copied from https://github.com/ask/celery/blob/2.4/contrib/generic-init.d/celerybeat | ||
|
||
### BEGIN INIT INFO | ||
# Provides: celerybeat | ||
# Required-Start: $network $local_fs $remote_fs | ||
# Required-Stop: $network $local_fs $remote_fs | ||
# Default-Start: 2 3 4 5 | ||
# Default-Stop: 0 1 6 | ||
# Short-Description: celery periodic task scheduler | ||
### END INIT INFO | ||
|
||
# Cannot use set -e/bash -e since the kill -0 command will abort | ||
# abnormally in the absence of a valid process ID. | ||
#set -e | ||
|
||
DEFAULT_PID_FILE="/var/run/celerybeat.pid" | ||
DEFAULT_LOG_FILE="/var/log/celerybeat.log" | ||
DEFAULT_LOG_LEVEL="INFO" | ||
DEFAULT_CELERYBEAT="celerybeat" | ||
|
||
# /etc/init.d/ssh: start and stop the celery task worker daemon. | ||
|
||
if test -f /etc/default/celeryd; then | ||
. /etc/default/celeryd | ||
fi | ||
|
||
if test -f /etc/default/celerybeat; then | ||
. /etc/default/celerybeat | ||
fi | ||
|
||
CELERYBEAT=${CELERYBEAT:-$DEFAULT_CELERYBEAT} | ||
CELERYBEAT_PID_FILE=${CELERYBEAT_PID_FILE:-${CELERYBEAT_PIDFILE:-$DEFAULT_PID_FILE}} | ||
CELERYBEAT_LOG_FILE=${CELERYBEAT_LOG_FILE:-${CELERYBEAT_LOGFILE:-$DEFAULT_LOG_FILE}} | ||
CELERYBEAT_LOG_LEVEL=${CELERYBEAT_LOG_LEVEL:-${CELERYBEAT_LOGLEVEL:-$DEFAULT_LOG_LEVEL}} | ||
|
||
export CELERY_LOADER | ||
|
||
CELERYBEAT_OPTS="$CELERYBEAT_OPTS -f $CELERYBEAT_LOG_FILE -l $CELERYBEAT_LOG_LEVEL" | ||
|
||
if [ -n "$2" ]; then | ||
CELERYBEAT_OPTS="$CELERYBEAT_OPTS $2" | ||
fi | ||
|
||
CELERYBEAT_LOG_DIR=`dirname $CELERYBEAT_LOG_FILE` | ||
CELERYBEAT_PID_DIR=`dirname $CELERYBEAT_PID_FILE` | ||
if [ ! -d "$CELERYBEAT_LOG_DIR" ]; then | ||
mkdir -p $CELERYBEAT_LOG_DIR | ||
fi | ||
if [ ! -d "$CELERYBEAT_PID_DIR" ]; then | ||
mkdir -p $CELERYBEAT_PID_DIR | ||
fi | ||
|
||
# Extra start-stop-daemon options, like user/group. | ||
if [ -n "$CELERYBEAT_USER" ]; then | ||
DAEMON_OPTS="$DAEMON_OPTS --uid $CELERYBEAT_USER" | ||
chown "$CELERYBEAT_USER" $CELERYBEAT_LOG_DIR $CELERYBEAT_PID_DIR | ||
fi | ||
if [ -n "$CELERYBEAT_GROUP" ]; then | ||
DAEMON_OPTS="$DAEMON_OPTS --gid $CELERYBEAT_GROUP" | ||
chgrp "$CELERYBEAT_GROUP" $CELERYBEAT_LOG_DIR $CELERYBEAT_PID_DIR | ||
fi | ||
|
||
CELERYBEAT_CHDIR=${CELERYBEAT_CHDIR:-$CELERYD_CHDIR} | ||
if [ -n "$CELERYBEAT_CHDIR" ]; then | ||
DAEMON_OPTS="$DAEMON_OPTS --workdir $CELERYBEAT_CHDIR" | ||
fi | ||
|
||
|
||
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" | ||
|
||
check_dev_null() { | ||
if [ ! -c /dev/null ]; then | ||
echo "/dev/null is not a character device!" | ||
exit 1 | ||
fi | ||
} | ||
|
||
wait_pid () { | ||
pid=$1 | ||
forever=1 | ||
i=0 | ||
while [ $forever -gt 0 ]; do | ||
kill -0 $pid 1>/dev/null 2>&1 | ||
if [ $? -eq 1 ]; then | ||
echo "OK" | ||
forever=0 | ||
else | ||
kill -TERM "$pid" | ||
i=$((i + 1)) | ||
if [ $i -gt 60 ]; then | ||
echo "ERROR" | ||
echo "Timed out while stopping (30s)" | ||
forever=0 | ||
else | ||
sleep 0.5 | ||
fi | ||
fi | ||
done | ||
} | ||
|
||
|
||
stop_beat () { | ||
echo -n "Stopping celerybeat... " | ||
if [ -f "$CELERYBEAT_PID_FILE" ]; then | ||
wait_pid $(cat "$CELERYBEAT_PID_FILE") | ||
else | ||
echo "NOT RUNNING" | ||
fi | ||
} | ||
|
||
start_beat () { | ||
echo "Starting celerybeat..." | ||
if [ -n "$VIRTUALENV" ]; then | ||
source $VIRTUALENV/bin/activate | ||
fi | ||
$CELERYBEAT $CELERYBEAT_OPTS $DAEMON_OPTS --detach \ | ||
--pidfile="$CELERYBEAT_PID_FILE" | ||
} | ||
|
||
|
||
|
||
case "$1" in | ||
start) | ||
check_dev_null | ||
start_beat | ||
;; | ||
stop) | ||
stop_beat | ||
;; | ||
reload|force-reload) | ||
echo "Use start+stop" | ||
;; | ||
restart) | ||
echo "Restarting celery periodic task scheduler" | ||
stop_beat | ||
check_dev_null | ||
start_beat | ||
;; | ||
|
||
*) | ||
echo "Usage: /etc/init.d/celerybeat {start|stop|restart}" | ||
exit 1 | ||
esac | ||
|
||
exit 0 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you want to put logs into git?