Skip to content
Go to file
Cannot retrieve contributors at this time
122 lines (89 sloc) 4.51 KB

Run builds using a worker

The PHP Censor Worker runs in the background on your server and waits for new builds to be added to a Beanstalkd queue. Unless already running a build, the worker will pick up and start running new builds almost immediately after their creation.

The worker is the recommended way to run PHP Censor builds. You can run several workers all watching one queue, allowing jobs to be run simultaneously without the overhead of polling your database.


  • You need to install Beanstalkd - On Ubuntu, this is as simple as running apt-get install beanstalkd.

  • Systemd or Supervisord needs to be installed and running on your server.

Setting up the PHP Censor worker

On a new installation

Setting up the worker on a new installation of PHP Censor is as simple as entering the appropriate values for your Beanstalkd server hostname and queue name when running the PHP Censor installer. By default, the installer assumes that you'll be using beanstalkd on localhost:11300 and will use the queue name php-censor-queue.

On an existing installation

On an existing installation, to set up the worker, you simply need to add the beanstalkd host and queue names directly into your config.yml file like:

    use_queue: true
    host:      localhost
    port:      11300
    name:      php-censor-queue
    lifetime:  600

Running the PHP Censor worker

By Systemd

You can use systemd to run the worker. Configuration for the unit is almost the same as supervisord's configuration. Just copy this config to /etc/systemd/system/php-censor.service with right permissions, enable systemctl enable php-censor.service and run it by systemctl start php-censor.service. If you want to start more than one worker, just create more unit files with different name and repeat previous steps.

Description=PHPCensor Worker

ExecStart=/your/path/bin/console php-censor:worker

#Could be changed

#Could be changed


And check that it works properly by systemctl status php-censor.service

By Supervisord

Also you can use Supervisord to run the worker. Once you've set up PHP Censor to add your jobs to a beanstalkd queue, you need to start the worker so that it can pick up and run your builds. On most servers, it is best to manage this using supervisord. The following instructions work on Ubuntu, but will need slight amendments for other distributions.

Using your preferred text editor, create a file named php-censor.conf under /etc/supervisor/conf.d. In it, enter the following config:

command=/path/to/php-censor/bin/console php-censor:worker

You'll need to edit the '/path/to/php-censor', the user value and the environment value to suit your server. The user needs to be an actual system user with suitable permissions to execute PHP and PHP Censor.

Once you've created this file, simply restart supervisord using the command service supervisor restart and 2 instances of PHP Censor's worker should start immediately. You can verify this by running the command ps aux | grep php-censor, which should give you output as follows:

➜  ~ ps aux | grep php-censor
php-censor    19057  0.0  0.9 200244 18720 ?        S    03:00   0:01 php /php-censor/console php-censor:worker
php-censor    19058  0.0  0.9 200244 18860 ?        S    03:00   0:01 php /php-censor/console php-censor:worker

Simple start with nohup (not recommended)

Also you can simple daemonise worker by nohup:

nohup /path/to/php-censor/bin/console php-censor:worker &> /var/log/php-censor-worker.log </dev/null & # and you can save pid in pidfile with echo "$!" > /var/run/, but it's not really necessary

But keep in mind: it won't restart your worker if it fails and can be inconvenient to manage worker process in contrast with other solutions. So, it's good for debug purposes or as temporary solution.

That's it! Now, whenever you create a new build in PHP Censor, it should start building immediately.

You can’t perform that action at this time.