Skip to content

Instantly share code, notes, and snippets.

View pcdinh's full-sized avatar

Pham Cong Dinh pcdinh

View GitHub Profile

Deploying an app for the first time

Remotely:

sudo mkdir /var/www/dashboard.app
sudo chown -R deploy:deploy /var/www/dashboard.app/

Locally:

cap deploy:setup

#! /bin/sh
# drupalir.sh, v 0.9.1
#
# Supplied by Quiptime Group
# Developed 2010 by Siegfried Neumann <[email protected]>
#
# This file is free software;
# you can redistribute it and/or modify it under the terms of the GNU
# General Public License as published by the Free Software Foundation.
"""
This is a simple Redis-based queue. Two features that I needed were
uniqueness (i.e. if an item exists in the queue already, it won't be
added again) and a delay like beanstalkd where an item must wait a
specified time before it can be popped from the queue. There are a
number of other Redis-based queues that have many more features but
I didn't see one that had these two features together. This 50-line
class works for my needs. It may or may not work for you. Feel free
to copy this and build on it.
1. Start gearman `server` on some machine (here `worker` machine):
$ gearmand --port 8888
2. Connect a `worker` to the server
$ gearman -h IP -p 8888 -w -f test wc
$ gearman -h 127.0.0.1 -p 8888 -w -f test executable_script
3. Push a job to queue by calling:
$ gearman -h IP -p 8888 -f test "SOME DATA TO PROCESS OR ARGS"
Notes:
* Gearman does NOT spawn any `worker` processes, therefore if a number of `workers`
sudo ifconfig eth0 192.168.1.50 netmask 255.255.255.0 up
sudo ifconfig eth0 hw 00:00:00:00:00:00
sudo route add default gw 172.16.236.0
Display current active Internet connections:
netstat -nat
Display open ports
sudo netstat -tulp || sudo netstat -tulpn
2 separated processes
=====================
+ Master agent which provides REST-like protocol. It is basically a socket server that supports minimum HTTP protocol
+ Worker agent, which is a big loop, is able to launch/close worker processes
Design
======
+ Trying not to abuse pcntl_fork() because I can not differentiate master agent process, worker agent process
<?php
declare(ticks = 1);
function handleExit($signal)
{
error_log("Caught a $signal signal, a worker process exiting\n", 3, './error-child-log');
exit(1);
}
pcntl_signal(SIGTERM, 'handleExit');
#!/usr/local/php5-fcgi/bin/php
<?php
$client = new GearmanClient();
$client->addServer('127.0.0.1');
echo "Sending 1000 job\n";
do
{
Simple snippets for http://github.com/alfredwesterveld/java-schedule-broadcaster
<?php
namespace bar;
class Test {}