Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Installing jobs system from scratch by itself on Debian 8.
2x Debian 8
- 2GB Ram
- 20GB disk
- selected: SSH server, and Standard Utilities
jobs1.test.local
eth0 - bridged, configured 10.0.1.12 (change depending on your network)
eth1 - lan, configured to 192.168.0.1 (change to suite your liking)
jobs2.test.local
eth0 - bridged, configured 10.0.1.13 (change depending on your network)
eth1 - lan, configured to 192.168.0.2 (change to suite your liking)
# more servers just follow the same instructions....
# dotdeb is for php7
wget https://www.dotdeb.org/dotdeb.gpg
apt-key add dotdeb.gpg
rm dotdeb.gpg
echo 'deb http://packages.dotdeb.org jessie all
> deb-src http://packages.dotdeb.org jessie all' > /etc/apt/sources.list.d/dotdeb.list
apt-get update
apt-get install mysql-server mysql-client php7.0 php7.0-mysql subversion vim-nox sudo curl strace
groupadd jobs
useradd jobs -g jobs -m -s /bin/bash
if [ ! -x /usr/local/bin/php ]; then ln -s "$(which php)" /usr/local/bin/php; fi
curl http://code.svn.wordpress.org/glockd/builds/312/linux-amd64/glockd.gz | gunzip > /usr/local/sbin/glockd
chmod a+rx /usr/local/sbin/glockd
sudo -u jobs -i
# These could be externals in your own repository
svn co http://code.svn.wordpress.org/jobs/core
svn co http://code.svn.wordpress.org/jobs/bin
svn co http://code.svn.wordpress.org/jobs/www
svn co http://core.svn.wordpress.org/tags/4.7.1/ wordpress
svn co https://plugins.svn.wordpress.org/hyperdb/tags/1.2/ hyperdb
mkdir var var/run var/log var/log/jobs
# Just on the MySQL Master
mysql -uroot -p -e 'CREATE DATABASE `jobstest`'
mysql -uroot -p -e 'GRANT ALL PRIVILEGES ON `jobstest`.* TO "jobsuser" identified by "ET[JtPYZsEJboPknRmGtWC3vFivvAP"'
php /home/jobs/bin/schema.php | mysql -ujobsuser -p -D jobstest
mysql -ujobsuser -p -D jobstest -e 'SHOW TABLES'
exit
sudo -u jobs curl -o /home/jobs/config.php \
'https://gist.githubusercontent.com/apokalyptik/8fec5f2471f48014ee0be4a76ff3546e/raw/config.php'
sudo -u jobs curl -o /home/jobs/config-www.php \
'https://gist.githubusercontent.com/apokalyptik/8fec5f2471f48014ee0be4a76ff3546e/raw/config-www.php'
sudo -u jobs curl -o /home/jobs/config-worker.php \
'https://gist.githubusercontent.com/apokalyptik/8fec5f2471f48014ee0be4a76ff3546e/raw/config-worker.php'
chown jobs:jobs /home/jobs/config.php
chown jobs:jobs /home/jobs/config-www.php
chown jobs:jobs /home/jobs/config-worker.php
curl -o /etc/systemd/system/jobs-jcron.service \
'https://gist.githubusercontent.com/apokalyptik/8fec5f2471f48014ee0be4a76ff3546e/raw/jobs-jcron.service'
curl -o /etc/systemd/system/jobs-manager.service \
'https://gist.githubusercontent.com/apokalyptik/8fec5f2471f48014ee0be4a76ff3546e/raw/jobs-manager.service'
curl -o /etc/systemd/system/lockd.service \
'https://gist.githubusercontent.com/apokalyptik/8fec5f2471f48014ee0be4a76ff3546e/raw/lockd.service'
curl -o /etc/apache2/conf-available/jobs-ui.conf \
'https://gist.githubusercontent.com/apokalyptik/8fec5f2471f48014ee0be4a76ff3546e/raw/jobs-ui.conf'
systemctl daemon-reload
systemctl enable lockd.service
systemctl enable jobs-manager.service
systemctl enable jobs-jcron.service
systemctl start lockd.service
systemctl start jobs-manager.service
systemctl start jobs-jcron.service
a2enconf jobs-ui
a2enmod rewrite
service apache2 restart
<?php
require dirname( __FILE__ ) . '/core/jobs.php';
<?php
define( 'DAEMONIZE', false );
require dirname( __FILE__ ) . '/config.php';
add_action( 'jobs_www_head', function() {
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Jobs System Dashboard</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>
<body>
<?php
} );
add_action( 'jobs_www_foot', function() {
?>
</body>
</html>
<?php
} );
<?php
date_default_timezone_set( "utc" );
ini_set( 'error_log', '/tmp/php-errors' );
ini_set( 'log_errors', 1 );
ini_set( 'error_reporting', E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED );
define( "JOBS_SYSTEM_ROOT", dirname( __FILE__ ) );
define( "DB_CONFIG_FILE", JOBS_SYSTEM_ROOT . '/hyperdb/db-config.php' );
# Locking
require dirname( __FILE__ ) . '/core/includes/lockd/lockd-client.php';
$lockc = new lockc();
# Define our database connection
define( "DB_USER", "jobsuser" );
define( "DB_PASSWORD", "ET[JtPYZsEJboPknRmGtWC3vFivvAP" );
define( "DB_HOST", "192.168.0.1" );
define( "DB_NAME", "jobstest" );
define( "SHORTINIT", true );
define( "WP_CONTENT_DIR", JOBS_SYSTEM_ROOT );
define( "WP_DEBUG", false );
define( "WP_DEBUG_DISPLAY", false );
define( "ABSPATH", JOBS_SYSTEM_ROOT . "/wordpress/" );
define( "WPINC", "wp-includes");
require ABSPATH . WPINC . "/plugin.php";
# Bring in HyperDB
require dirname( __FILE__ ) . "/hyperdb/db.php";
require ABSPATH . WPINC . "/load.php";
# Configure log and pidfiles to be relative to the location of this config file
function jobs_cfg_path( $fn ) {
return rtrim( JOBS_SYSTEM_ROOT, "/" ) . "/" . ltrim( $fn, "/" );
}
add_filter( 'cfg_jan_logfile', 'jobs_cfg_path' );
add_filter( 'cfg_jan_worker_stderr_glob', 'jobs_cfg_path' );
add_filter( 'cfg_crn_pidfile', 'jobs_cfg_path' );
add_filter( 'cfg_crn_logfile', 'jobs_cfg_path' );
add_filter( 'cfg_mgr_pidfile', 'jobs_cfg_path' );
add_filter( 'cfg_mgr_logfile', 'jobs_cfg_path' );
add_filter( 'cfg_mgr_worker_logfile', 'jobs_cfg_path' );
add_filter( 'cfg_mgr_janitor_logfile', 'jobs_cfg_path' );
add_filter( 'cfg_wkr_logfile', 'jobs_cfg_path' );
add_filter( 'cfg_wkr_external_logfile', 'jobs_cfg_path' );
define( 'IS_JOBS', true );
if ( !defined( 'SYSTEM_PREFIX' ) )
define( 'SYSTEM_PREFIX', 'jobs_' );
require JOBS_SYSTEM_ROOT . '/core/includes/queue.php';
require JOBS_SYSTEM_ROOT . '/core/daemon.php';
if ( !defined( 'DAEMONIZE' ) )
define( 'DAEMONIZE', true );
daemonize( DAEMONIZE );
ob_start();
require JOBS_SYSTEM_ROOT . '/core/includes/counters.php';
ob_end_clean();
# /etc/systemd/system/jobs-jcron.service
[Unit]
Description=Jobs System Scheduler
[Service]
WorkingDirectory=/home/jobs/
ExecStart=/home/jobs/core/jcron.php
User=jobs
Type=forking
PIDFile=/home/jobs/var/run/jobs_jcron.pid
Restart=always
KillMode=process
KillSignal=SIGKILL
Requires=mysql.service lockd.service jobs-manager.service network-online.target
[Install]
WantedBy=multi-user.target
# /etc/systemd/system/jobs-manager.service
[Unit]
Description=Jobs System Manager
[Service]
WorkingDirectory=/home/jobs/
ExecStart=/home/jobs/core/manager.php
User=jobs
Type=forking
PIDFile=/home/jobs/var/run/jobs_manager.pid
Restart=always
KillMode=process
KillSignal=SIGKILL
Requires=mysql.service lockd.service network-online.target
[Install]
WantedBy=multi-user.target
Alias "/jobs" "/home/jobs/www"
<Directory "/home/jobs/www/">
DirectoryIndex jobs.php
Require all granted
Options ALL
RewriteEngine On
RewriteBase "/jobs/"
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . jobs.php [L,NE]
</Directory>
# /etc/systemd/system/lockd.service
[Unit]
Description=Lockd
[Service]
WorkingDirectory=/home/jobs/
ExecStart=/usr/local/sbin/glockd -pidfile=/home/jobs/var/run/lockd.pid -port=2626 -ws=0
User=jobs
PIDFile=/home/jobs/var/run/lockd.pid
Restart=always
[Install]
WantedBy=multi-user.target network-online.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.