Skip to content

Commit

Permalink
Merge branch '0.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbaum committed Sep 19, 2017
2 parents fced9d3 + f916e08 commit 4ed4713
Show file tree
Hide file tree
Showing 12 changed files with 203 additions and 21 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Laravel-Artisan Cookbook Changelog

## 0.5.0
* Added support of `php artisan migrate:status`

## 0.4.0
* Added support of `php artisan schedule:run`
* Added a possibility to disable running of `php artisan schedule:run`
Expand Down
27 changes: 16 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ Commands that are particular useful for development are not supported.
* cache:clear
* config:cache
* config:clear
* migrate:status
* package:discover
* queue:work
* schedule:run
* view:clear

Expand Down Expand Up @@ -76,14 +78,17 @@ Using AWS Opsworks you can pass in the path via custom json:
```

### Recipes
* `laravel-artisan::clear-compiled` Remove the compiled class file
* `laravel-artisan::down` Put the application into maintenance mode.
* `laravel-artisan::env` Display the current framework environment.
* `laravel-aritsan::up` Bring the application out of maintenance mode.
* `laravel-artisan::cache_clear` Flush the application cache.
* `laravel-artisan::config_cache` Create a cache file for faster configuration loading.
* `laravel-artisan::config_clear` Remove the configuaration cache file.
* `laravel-artisan::package_discover` Rebuild the cached package manifest.
* `laravel-artisan::schedule_run` Run the scheduled commands.
* `laravel-artisan::schedule_remove` Remove the cronjob that runs `php artisan schedule:run`
* `laravel-artisan::view_clear` Clear all compiled view files.
* `laravel-artisan::clear-compiled` - Remove the compiled class file
* `laravel-artisan::down` - Put the application into maintenance mode.
* `laravel-artisan::env` - Display the current framework environment.
* `laravel-aritsan::up` - Bring the application out of maintenance mode.
* `laravel-artisan::cache_clear` - Flush the application cache.
* `laravel-artisan::config_cache` - Create a cache file for faster configuration loading.
* `laravel-artisan::config_clear` - Remove the configuaration cache file.
* `laravel-artisan::migrate_status` - Show the status of each migration.
* `laravel-artisan::package_discover` - Rebuild the cached package manifest.
* `laravel-artisan::queue_work` - Start processing jobs on the queue as a daemon.
* `laravel-artisan::queue_stop` - Stop processing jobs on the queue as a daemon.
* `laravel-artisan::schedule_run` - Run the scheduled commands.
* `laravel-artisan::schedule_remove` - Remove the cronjob that runs `php artisan schedule:run`
* `laravel-artisan::view_clear` - Clear all compiled view files.
8 changes: 8 additions & 0 deletions attributes/queue.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
default['laravel-artisan']['queue']['worker_name'] = 'laravel-worker'
default['laravel-artisan']['queue']['command'] = "php #{node['laravel-artisan']['path']}/artisan queue:work"
default['laravel-artisan']['queue']['autostart'] = true
default['laravel-artisan']['queue']['autorestart'] = true
default['laravel-artisan']['queue']['redirect_stderr'] = true
default['laravel-artisan']['queue']['user'] = 'www-data'
default['laravel-artisan']['queue']['stdout_logfile'] = "/var/log/supervisor/#{node['laravel-artisan']['queue']['worker_name']}.log"
default['laravel-artisan']['queue']['numprocs'] = 1
1 change: 1 addition & 0 deletions attributes/supervisor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default['laravel-artisan']['supervisor']['conf_dir'] = "/etc/supervisor/conf.d"
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license 'Apache-2.0'
description "Run laravel's artisan commands"
long_description "Run laravel's artisan commands on remote nodes"
version '0.4.0'
version '0.5.0'
chef_version '>= 12.1' if respond_to?(:chef_version)
supports 'ubuntu', '= 16.04'

Expand Down
11 changes: 3 additions & 8 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,17 @@
# and check that the path to the executable is set properly.


## Check if the path to the artisan file is given
### Check if the path to the artisan file is given
if node['laravel-artisan']['path'].empty?
raise(Exception, 'Missing path to artisan file!');
end

# Check if the artisan file exists at the given location
### Check if the artisan file exists at the given location
unless File.exists?("#{node['laravel-artisan']['path']}/artisan")
raise(Exception, "No artisan file at the given locatation: #{node['laravel-artisan']['path']}")
end

### Log that all checks have passed
log 'checking laravel artisan prerequisits' do
message 'Laravel artsan prerequisits check [SUCCESS]'
end

#execute 'php artisan help' do
# cwd node['laravel-artisan']['path']
# command "#{node['laravel-artisan']['call']} help #{node['laravel-artisan']['verbosity']}"
# action :run
#end
15 changes: 15 additions & 0 deletions recipes/migrate_status.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Cookbook:: laravel-artisan
# Recipe:: migrate_status
#
# Copyright:: 2017, The Authors, All Rights Reserved.

include_recipe 'laravel-artisan::default'

COMMAND = 'migrate:status'

execute "php artisan #{COMMAND}" do
cwd node['laravel-artisan']['path']
command "#{node['laravel-artisan']['call']} #{COMMAND} #{node['laravel-artisan']['verbosity']}"
action :run
end
25 changes: 25 additions & 0 deletions recipes/queue_stop.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Stop the artisan queue:work process.
#
# Cookbook:: laravel-artisan
# Recipe:: queue_stop
#
# Copyright:: 2017, The Authors, All Rights Reserved.

### Remove the supervisor configuration for queue:work
file "remove supervisor conf for #{node['laravel-artisan']['queue']['worker_name']}" do
path "#{node['laravel-artisan']['supervisor']['conf_dir']}/#{node['laravel-artisan']['queue']['worker_name']}.conf"
action :delete
end

### Stop supervisor
service 'stop supervisor' do
service_name 'supervisor'
action :stop
end

### Start supervisor
service 'start supervisor' do
service_name 'supervisor'
action :start
end

39 changes: 39 additions & 0 deletions recipes/queue_work.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Start a laravel queue worker process.
#
# In order to run it as a service supervisor is installed and configured.
# For more details see:
# - https://laravel.com/docs/5.5/queues#supervisor-configuration
#
#
# Cookbook:: laravel-artisan
# Recipe:: queue_work
#
# Copyright:: 2017, The Authors, All Rights Reserved.

include_recipe 'laravel-artisan::default'

### Install and prepare supervisor
include_recipe 'laravel-artisan::supervisor'

template "create supervisor conf for #{node['laravel-artisan']['queue']['worker_name']}" do
source 'supervisor.conf.erb'
path "#{node['laravel-artisan']['supervisor']['conf_dir']}/#{node['laravel-artisan']['queue']['worker_name']}.conf"
owner 'root'
group 'root'
mode '0644'
variables node['laravel-artisan']['queue']
end

### Stop the supervisor service
service 'stop supervisor' do
service_name 'supervisor'
supports :stop => true, :status => true, :restart => true, :reload => true
action :stop
end

### Start the supervisor service
service 'start supervisor' do
service_name 'supervisor'
supports :start => true, :status => true, :restart => true, :reload => true
action :start
end
2 changes: 1 addition & 1 deletion recipes/schedule_remove.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# Copyright:: 2017, The Authors, All Rights Reserved.


### Remove the crontab entry for the scheduler
cron "laravel-scheduler" do
action :delete
end
12 changes: 12 additions & 0 deletions recipes/supervisor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Install and prepare supervisor
#
# Cookbook:: laravel-artisan
# Recipe:: supervisor
#
# Copyright:: 2017, The Authors, All Rights Reserved.

### Install supervisor from package repository
package 'supervisor' do
action :install
end

79 changes: 79 additions & 0 deletions templates/supervisor.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
; Program supervisor config file.
;
; For more information on the config file, please see:
; http://supervisord.org/configuration.html
;

[program:<%= @worker_name %>]
command=<%= @command %> ; the program (relative uses PATH, can take args)
process_name=%(program_name)s_%(process_num)02d ; process_name expr (default %(program_name)s)
numprocs=<%= @numprocs %> ; number of processes copies to start (def 1)
;directory=/tmp ; directory to cwd to before exec (def no cwd)
;umask=022 ; umask for process (default None)
;priority=999 ; the relative start priority (default 999)
autostart=<%= @autostart %> ; start at supervisord start (default: true)
;startsecs=1 ; # of secs prog must stay up to be running (def. 1)
;startretries=3 ; max # of serial start failures when starting (default 3)
autorestart=<%= @autorestart %> ; when to restart if exited after running (def: unexpected)
;exitcodes=0,2 ; 'expected' exit codes used with autorestart (default 0,2)
;stopsignal=QUIT ; signal used to kill process (default TERM)
;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
;stopasgroup=false ; send stop signal to the UNIX process group (default false)
;killasgroup=false ; SIGKILL the UNIX process group (def false)
user=<%= @user %> ; setuid to this UNIX account to run the program
redirect_stderr=<%= @redirect_stderr %> ; redirect proc stderr to stdout (default false)
stdout_logfile=<%= @stdout_logfile %> ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups=10 ; # of stdout logfile backups (0 means none, default 10)
;stdout_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
;stdout_events_enabled=false ; emit events on stdout writes (default false)
;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups=10 ; # of stderr logfile backups (0 means none, default 10)
;stderr_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
;stderr_events_enabled=false ; emit events on stderr writes (default false)
;environment=A="1",B="2" ; process environment additions (def no adds)
;serverurl=AUTO ; override serverurl computation (childutils)

; The sample eventlistener section below shows all possible eventlistener
; subsection values. Create one or more 'real' eventlistener: sections to be
; able to handle event notifications sent by supervisord.

;[eventlistener:theeventlistenername]
;command=/bin/eventlistener ; the program (relative uses PATH, can take args)
;process_name=%(program_name)s ; process_name expr (default %(program_name)s)
;numprocs=1 ; number of processes copies to start (def 1)
;events=EVENT ; event notif. types to subscribe to (req'd)
;buffer_size=10 ; event buffer queue size (default 10)
;directory=/tmp ; directory to cwd to before exec (def no cwd)
;umask=022 ; umask for process (default None)
;priority=-1 ; the relative start priority (default -1)
;autostart=true ; start at supervisord start (default: true)
;startsecs=1 ; # of secs prog must stay up to be running (def. 1)
;startretries=3 ; max # of serial start failures when starting (default 3)
;autorestart=unexpected ; autorestart if exited after running (def: unexpected)
;exitcodes=0,2 ; 'expected' exit codes used with autorestart (default 0,2)
;stopsignal=QUIT ; signal used to kill process (default TERM)
;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
;stopasgroup=false ; send stop signal to the UNIX process group (default false)
;killasgroup=false ; SIGKILL the UNIX process group (def false)
;user=chrism ; setuid to this UNIX account to run the program
;redirect_stderr=false ; redirect_stderr=true is not allowed for eventlisteners
;stdout_logfile=/a/path ; stdout log path, NONE for none; default AUTO
;stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
;stdout_logfile_backups=10 ; # of stdout logfile backups (0 means none, default 10)
;stdout_events_enabled=false ; emit events on stdout writes (default false)
;stderr_logfile=/a/path ; stderr log path, NONE for none; default AUTO
;stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
;stderr_logfile_backups=10 ; # of stderr logfile backups (0 means none, default 10)
;stderr_events_enabled=false ; emit events on stderr writes (default false)
;environment=A="1",B="2" ; process environment additions
;serverurl=AUTO ; override serverurl computation (childutils)

; The sample group section below shows all possible group values. Create one
; or more 'real' group: sections to create "heterogeneous" process groups.

;[group:thegroupname]
;programs=progname1,progname2 ; each refers to 'x' in [program:x] definitions
;priority=999 ; the relative start priority (default 999)

0 comments on commit 4ed4713

Please sign in to comment.