Chef-Provisioning-Vagrant: Wheres the machine? - vagrant

I'm attempting to use Chef-Provisioning to spin up some Vagrant VMs. The chef-client -z provision.rb command runs and successfully completes. I know that the machine, or something exists out there because it idempotently completes this run with no changes when I rerun the command.
Inside knife.rb I define the profiles:
profiles({
'default' => {
},
'ubuntu_vagrant' => {
:driver => 'vagrant:',
:machine_options => {
:vagrant_options => {
'vm.box' => 'chef/ubuntu-14.04',
}
}
},
'ubuntu_docker' => {
:driver => 'docker',
:machine_options => {
:docker_options => {
:base_image => {
:name => 'ubuntu',
:tag => '14.04.2'
}
}
}
}
})
Then I execute sudo CHEF_PROFILE=ubuntu_vagrant chef-client -z provision.rb
provision.rb:
machine 'webserver' do
recipe 'djnginx'
end
Results:
sudo CHEF_PROFILE=ubuntu_vagrant chef-client -z provision.rb
[2015-04-18T13:13:23-08:00] INFO: Started chef-zero at http://localhost:8889 with repository at /Users/djenriquez/chef-repo
One version per cookbook
[2015-04-18T13:13:23-08:00] INFO: Forking chef instance to converge...
Starting Chef Client, version 12.2.1
[2015-04-18T13:13:23-08:00] INFO: *** Chef 12.2.1 ***
[2015-04-18T13:13:23-08:00] INFO: Chef-client pid: 948
[2015-04-18T13:13:26-08:00] INFO: Run List is []
[2015-04-18T13:13:26-08:00] INFO: Run List expands to []
[2015-04-18T13:13:26-08:00] INFO: Starting Chef Run for djenriquez07
[2015-04-18T13:13:26-08:00] INFO: Running start handlers
[2015-04-18T13:13:26-08:00] INFO: Start handlers complete.
[2015-04-18T13:13:26-08:00] INFO: HTTP Request Returned 404 Not Found : Object not found: /reports/nodes/djenriquez07/runs
resolving cookbooks for run list: []
[2015-04-18T13:13:26-08:00] INFO: Loading cookbooks []
Synchronizing Cookbooks:
Compiling Cookbooks...
[2015-04-18T13:13:26-08:00] WARN: Node djenriquez07 has an empty run list.
Converging 1 resources
Recipe: #recipe_files::/Users/djenriquez/chef-repo/cookbooks/djnginx/provision.rb
* machine[webserver] action converge[2015-04-18T13:13:26-08:00] INFO: Processing machine[webserver] action converge (#recipe_files::/Users/djenriquez/chef-repo/cookbooks/djnginx/provision.rb line 1)
[2015-04-18T13:13:26-08:00] INFO: Processing vagrant_cluster[/] action create (basic_chef_client::block line 212)
[2015-04-18T13:13:26-08:00] INFO: Processing directory[/] action create (basic_chef_client::block line 15)
[2015-04-18T13:13:26-08:00] INFO: Processing file[/Vagrantfile] action create (basic_chef_client::block line 16)
[2015-04-18T13:13:26-08:00] INFO: Processing file[/webserver.vm] action create (basic_chef_client::block line 232)
[2015-04-18T13:13:26-08:00] INFO: Processing chef_node[webserver] action create (basic_chef_client::block line 57)
[2015-04-18T13:13:31-08:00] INFO: Processing chef_node[webserver] action create (basic_chef_client::block line 57)
[2015-04-18T13:13:31-08:00] INFO: Executing sudo cp /etc/chef/client.pem /tmp/client.pem.1379680942 on vagrant#127.0.0.1
[2015-04-18T13:13:32-08:00] INFO: Completed cp /etc/chef/client.pem /tmp/client.pem.1379680942 on vagrant#127.0.0.1: exit status 0
[2015-04-18T13:13:32-08:00] INFO: Executing sudo chown vagrant /tmp/client.pem.1379680942 on vagrant#127.0.0.1
[2015-04-18T13:13:32-08:00] INFO: Completed chown vagrant /tmp/client.pem.1379680942 on vagrant#127.0.0.1: exit status 0
[2015-04-18T13:13:32-08:00] INFO: Executing sudo rm /tmp/client.pem.1379680942 on vagrant#127.0.0.1
[2015-04-18T13:13:32-08:00] INFO: Completed rm /tmp/client.pem.1379680942 on vagrant#127.0.0.1: exit status 0
[2015-04-18T13:13:32-08:00] INFO: Processing chef_client[webserver] action create (basic_chef_client::block line 131)
[2015-04-18T13:13:32-08:00] INFO: Processing chef_node[webserver] action create (basic_chef_client::block line 142)
[2015-04-18T13:13:32-08:00] INFO: Port forwarded: local URL http://localhost:8889 is available to 127.0.0.1 as http://localhost:8889 for the duration of this SSH connection.
[2015-04-18T13:13:32-08:00] INFO: Executing sudo ls -d /etc/chef/client.rb on vagrant#127.0.0.1
[2015-04-18T13:13:32-08:00] INFO: Completed ls -d /etc/chef/client.rb on vagrant#127.0.0.1: exit status 0
[2015-04-18T13:13:32-08:00] INFO: Executing sudo md5sum -b /etc/chef/client.rb on vagrant#127.0.0.1
[2015-04-18T13:13:32-08:00] INFO: Completed md5sum -b /etc/chef/client.rb on vagrant#127.0.0.1: exit status 0
[2015-04-18T13:13:32-08:00] INFO: Executing sudo chef-client -v on vagrant#127.0.0.1
[2015-04-18T13:13:33-08:00] INFO: Completed chef-client -v on vagrant#127.0.0.1: exit status 0
[2015-04-18T13:13:33-08:00] INFO: Processing chef_node[webserver] action create (basic_chef_client::block line 57)
(up to date)
[2015-04-18T13:13:33-08:00] INFO: Chef Run complete in 6.688063 seconds
Running handlers:
[2015-04-18T13:13:33-08:00] INFO: Running report handlers
Running handlers complete
[2015-04-18T13:13:33-08:00] INFO: Report handlers complete
Chef Client finished, 0/1 resources updated in 9.993406 seconds
But I look at virutalbox and I do not see a VM created for this instance, nor can I visit the static nginx page created by the djnginx cookbook.
Where the heck is my VM? Or does Chef-provisioning not actually create a vagrant VM for me??
If I create a Vagrantfile for this cookbook and run vagrant up, the VM is spun-up and the static nginx page is available for me to navigate to.

The Vagrant machines by default are stored in “.chef/vms”. You can see their status by going to this directory and running normal vagrant commands, e.g.:
cd .chef/vms
vagrant status
You can also use the vagrant global-status command to see the status of any VM on your workstation. This is a useful command because it also gives you a global ID that you can use to issue vagrant commands on any VM, rather than having to find the directory with the Vagrantfile.

You may want to set converge true in your machine resource, at least while testing. It doesn't appear to have run your recipe on the created VM. Appears to have created a VM and successfully run linux commands on it, so even if you can't find it, it's running.

Related

Packer error with build from vmx file - "file was not found"

I have a problem that I can't figure out. I'm trying to make my first clone of a VM from Packer (Hashicorp) here is my HCL :
source "vmware-vmx" "basic-example" {
source_path = "D:/HashiCorp/Packer1.8.0/Project/WindowsServer2022.vmx"
vm_name = "Test1"
communicator = "winrm"
winrm_host = "redteam"
winrm_username = "admin"
winrm_password = "Disc0very"
shutdown_command = "shutdown /s"
}
build {
sources = ["sources.vmware-vmx.basic-example"]
}
and when I run my build command I get this result :
D:\HashiCorp\Packer1.8.0\Project>packer build packer_test_win2022CARL.pkr.hcl
vmware-vmx.basic-example: output will be in this color.
==> vmware-vmx.basic-example: Configuring output and export directories...
==> vmware-vmx.basic-example: Creating required virtual machine disks
==> vmware-vmx.basic-example: Cloning source VM...
==> vmware-vmx.basic-example: Deleting output directory...
Build 'vmware-vmx.basic-example' errored after 521 milliseconds 605 microseconds: VMware error: Error: A file was not found
==> Wait completed after 521 milliseconds 605 microseconds
==> Some builds didn't complete successfully and had errors:
--> vmware-vmx.basic-example: VMware error: Error: A file was not found
==> Builds finished but no artifacts were created.
Solved, not enough to point the VMX file, VMware needs other files such as .vmdk, .vmxf etc ... to proceed with the cloning

Docker chef cookbook on windows

I am using chef client to run cookbook with docker. It run on Ubuntu, but gives error on windows. Dependency of docker is already added in cookbook.
https://supermarket.chef.io/cookbooks/docker
I am using example of docker cookbook.
docker_image 'busybox' do
action :pull
end
Error :
Recipe: tomcatcookbook::default
* docker_image[busybox] action pull[2017-11-01T14:02:43+05:30] INFO: Processing docker_image[busybox] action pull (tomcatcookbook::default line 6)
================================================================================
Error executing action `pull` on resource 'docker_image[busybox]'
================================================================================
Excon::Error::Socket
--------------------
An address incompatible with the requested protocol was used. - socket(2) (Errno::EAFNOSUPPORT)
Resource Declaration:
---------------------
# In C:/chef/cache/cookbooks/tomcatcookbook/recipes/default.rb
6: docker_image 'busybox' do
7: action :pull
8: end
9:
Compiled Resource:
------------------
# Declared in C:/chef/cache/cookbooks/tomcatcookbook/recipes/default.rb:6:in `from_file'
docker_image("busybox") do
action [:pull]
default_guard_interpreter :default
declared_type :docker_image
cookbook_name "tomcatcookbook"
recipe_name "default"
repo "busybox"
connection #<Docker::Connection:0x0000000005a288c0 #url="unix:///", #options={:socket=>"/var/run/docker.sock", :read_timeout=>120}>
end
System Info:
------------
chef_version=13.5.3
platform=windows
platform_version=10.0.15063
ruby=ruby 2.4.2p198 (2017-09-14 revision 59899) [x64-mingw32]
program_name=C:/opscode/chef/bin/chef-client
executable=C:/opscode/chef/bin/chef-client
[2017-11-01T14:02:44+05:30] INFO: Running queued delayed notifications before re-raising exception
As you can see in the documentation (the platform support list), Windows is not supported by that cookbook.

Chef remote_directory cookbook #recipe_files not found

I've created a simple recipe to copy files from one directory to another on windows.
Recipe:
remote_directory 'C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination' do
source 'C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\source'
action :create
end
However, I'm getting the following error when trying to execute the recipe in --local-mode for the sake of testing the recipe before deploying it on Chef server:
PS C:\chef-repo\chef-repo\cookbooks\chef-repo> chef-client
--local-mode .\copyBinaries.rb [2017-08-08T13:34:03+03:00] INFO: Started chef-zero at chefzero://localhost:1 with repository at C:/chef-repo/chef-repo One version per cookbook
Starting Chef Client, version 13.2.20 [2017-08-08T13:34:03+03:00] INFO: *** Chef 13.2.20 *** [2017-08-08T13:34:03+03:00] INFO: Platform: i386-mingw32 [2017-08-08T13:34:03+03:00] INFO: Chef-client pid: 10708 [2017-08-08T13:34:03+03:00] INFO: The plugin path C:\chef\ohai\plugins does not exist. Skipping... [2017-08-08T13:34:12+03:00] INFO: Run List is [] [2017-08-08T13:34:12+03:00] INFO: Run List expands to [] [2017-08-08T13:34:12+03:00] INFO: Starting Chef Run for mohammedr [2017-08-08T13:34:12+03:00] INFO: Running start handlers [2017-08-08T13:34:12+03:00] INFO: Start handlers complete. resolving cookbooks for run list: [] [2017-08-08T13:34:12+03:00] INFO: Loading cookbooks [] Synchronizing Cookbooks: Installing Cookbook Gems: Compiling Cookbooks... [2017-08-08T13:34:12+03:00] WARN: Node mohammedr has an empty run list. Converging 1 resources Recipe: #recipe_files::C:/chef-repo/chef-repo/cookbooks/chef-repo/copyBinaries.rb
* remote_directory[C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination] action create[2017-08-08T13:34:12+03:00] INFO: Processing remote_directory[C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination] action create (#recipe_files::C:/chef-repo/chef-repo/cookbooks/chef-repo/copyBinaries.rb line 7)
================================================================================
Error executing action `create` on resource 'remote_directory[C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination]'
================================================================================
Chef::Exceptions::CookbookNotFound
----------------------------------
Cookbook #recipe_files not found. If you're loading #recipe_files from another cookbook, make sure you configure the dependency in your metadata
Resource Declaration:
---------------------
# In C:/chef-repo/chef-repo/cookbooks/chef-repo/copyBinaries.rb
7: remote_directory 'C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination' do
8: source 'C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\source'
9: action :create
10: end
11:
Compiled Resource:
------------------
# Declared in C:/chef-repo/chef-repo/cookbooks/chef-repo/copyBinaries.rb:7:in `from_file'
remote_directory("C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination") do
action [:create]
default_guard_interpreter :default
path "C:\\chef-repo\\chef-repo\\cookbooks\\chef-repo\\recipes\\destination"
recursive true
source "C:\\chef-repo\\chef-repo\\cookbooks\\chef-repo\\recipes\\source"
files_backup 5
files_owner nil
files_group nil
overwrite true
declared_type :remote_directory
cookbook_name "#recipe_files"
recipe_name "C:/chef-repo/chef-repo/cookbooks/chef-repo/copyBinaries.rb"
mode nil
owner nil
group nil
files_mode nil
end
System Info:
------------
chef_version=13.2.20
platform=windows
platform_version=10.0.14393
ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [i386-mingw32]
program_name=C:/opscode/chefdk/modules/chef/../../bin/chef-client
executable=C:/opscode/chefdk/bin/chef-client
[2017-08-08T13:34:12+03:00] INFO: Running queued delayed notifications before re-raising exception
Running handlers: [2017-08-08T13:34:12+03:00] ERROR: Running exception handlers Running handlers complete [2017-08-08T13:34:12+03:00] ERROR: Exception handlers complete Chef Client failed. 0 resources updated in 09 seconds [2017-08-08T13:34:12+03:00] FATAL: Stacktrace dumped to c:/chef-repo/chef-repo/.chef/local-mode-cache/cache/chef-stacktrace.out [2017-08-08T13:34:12+03:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report [2017-08-08T13:34:12+03:00] FATAL: Chef::Exceptions::CookbookNotFound: remote_directory[C:\chef-repo\chef-repo\cookbooks\chef-repo\recipes\destination] (#recipe_files::C:/chef-repo/chef-repo/cookbooks/chef-repo/copyBinaries.rb line 7) had an error: Chef::Exceptions::CookbookNotFound: Cookbook #recipe_files not found. If you're loading #recipe_files from another cookbook, make sure you configure the dependency in your metadata
I've tried searching the internet for a solution regarding this issue, but I couldn't find anything useful.
The remote_directory resource takes files from the cookbook's files/ folder.
What you do looks pretty weird to me - you're copying recipes, and you're hardcoding local paths to the cookbook. Better ask a new question including your actual goal. I'm pretty confident that remote_directory is not what you want.

Chef, Vagrant and private git cloning

i have acces to git repo on host, and i have a Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu14.04"
config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64- vagrant-disk1.box"
config.vm.provider "virtualbox" do |vb|
vb.memory = 1024
vb.cpus = 2
end
config.ssh.forward_agent = true
config.vm.provision :chef_solo do |chef|
# chef.log_level = :debug
chef.cookbooks_path = "./cookbooks"
chef.add_recipe "git_sync"
end
end
if i run vagrant and ssh into it, i could also git clone my private repo, (recipe "install_pkgs" is to install git on vm) but the pecipe "git_sync" gets an error like:
[2015-05-08T18:40:26+00:00] ERROR: Running exception handlers
[2015-05-08T18:40:26+00:00] ERROR: Exception handlers complete
[2015-05-08T18:40:26+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2015-05-08T18:40:26+00:00] ERROR: git[/home/vagrant/geomongo] (git_sync::default line 1) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '128'
---- Begin output of git ls-remote "git#bitbucket.org:galiaf95/test.git" HEAD ----
STDOUT:
STDERR: Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
---- End output of git ls-remote "git#bitbucket.org:galiaf95/test.git" HEAD ----
Ran git ls-remote "git#bitbucket.org:galiaf95/test.git" HEAD returned 128
================================================================================
Error executing action `sync` on resource 'git[/home/vagrant/geomongo]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '128'
---- Begin output of git ls-remote "git#bitbucket.org:galiaf95/test.git" HEAD ----
STDOUT:
STDERR: Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
---- End output of git ls-remote "git#bitbucket.org:galiaf95/test.git" HEAD ----
Ran git ls-remote "git#bitbucket.org:galiaf95/test.git" HEAD returned 128
Resource Declaration:
---------------------
# In /tmp/vagrant-chef-1/chef-solo-1/cookbooks/git_sync/recipes/default.rb
1: git "/home/vagrant/geomongo" do
2: # repository "git#bitbucket.org:osll/geomongo.git"
3: # repository "https://github.com/galiaf95/test.git"
4: repository "git#bitbucket.org:galiaf95/test.git"
5: action :sync
6: end
Compiled Resource:
------------------
# Declared in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/git_sync/recipes/default.rb:1:in `from_file'
git("/home/vagrant/geomongo") do
provider Chef::Provider::Git
action [:sync]
retries 0
retry_delay 2
destination "/home/vagrant/geomongo"
revision "HEAD"
remote "origin"
cookbook_name :git_sync
recipe_name "default"
repository "git#bitbucket.org:galiaf95/test.git"
end
[2015-05-08T18:38:31+00:00] INFO: Forking chef instance to converge...
[2015-05-08T18:40:26+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the
output above. Please fix your recipes so that they properly complete.
Here is my git_sync.rb recipe
git "/home/vagrant/geomongo" do"
repository "git#bitbucket.org:galiaf95/test.git"
action :sync
end
I'm new to chef and vagrant and it would be great to have some very comprehensive examples of how to clone private repo using chef.
Problem solved with this post https://stackoverflow.com/a/8191279/3564452 But can someone, please, discribe what's going on in this recipe and how this fixes my problem.
(I'm no chef expert, but I have a similar setup working with Salt...)
The issue is that when you log on, you set up the ssh known_host as the user "vagrant", and the SSH_AUTH_SOCK variable is set for that user too. When you run your Chef recipes in the provisioner, they run as root. So, you need to add your host to the /root/.ssh/known_hosts and also you need to edit /etc/sudoers to allow SSH_AUTH_SOCK to be passed through, something like so, although you'll obviously need to port my salt-call line to Chef.
config.vm.provision "setup-and-highstate", type: "shell" do |s|
s.inline = <<SCRIPT
grep -s SSH_AUTH_SOCK /etc/sudoers || echo 'Defaults env_keep="SSH_AUTH_SOCK"' | (EDITOR="tee -a" visudo)
ln -s /var/cache/salt/minion/extmods/outputters/ /var/cache/salt/minion/extmods/output
salt-call --local 'ssh.set_known_host' 'root' enc='ecdsa' fingerprint='ff:ff:ff:23:b4:20:93:d1:2e:91:ff:3c:a8:ff' hostname='git.xxxx.yyyy.com'
SCRIPT
end
With the error string Host key verification failed. to me it sounds like one of three things:
you didn't add your SSH keys to your BitBucket repository
the SSH key on your node is formatted incorrectly (a trailing space or newline for instance)
you didn't ssh-add your SSH key on your node
In regards to the HOSTS issue, you can use the ssh_known_hosts cookbook resource to add the git#bitbucket.org address prior to using the git resource.

How to stop God from leaving stale Resque worker processes?

I'm trying to understand how to monitor the resque worker for travis-ci with god in such a way that stopping the resque watch via god won't leave a stale worker process.
In the following I'm talking about the worker process, not forked job child processes (i.e. the queue is empty all the time).
When I manually start the resque worker like this:
$ QUEUE=builds rake resque:work
I'll get a single process:
$ ps x | grep resque
7041 s001 S+ 0:05.04 resque-1.13.0: Waiting for builds
And this process will go away as soon as I stop the worker task.
But when I start the same thing with god (exact configuration is here, basically the same thing as the resque/god example) like this ...
$ RAILS_ENV=development god -c config/resque.god -D
I [2011-03-27 22:49:15] INFO: Loading config/resque.god
I [2011-03-27 22:49:15] INFO: Syslog enabled.
I [2011-03-27 22:49:15] INFO: Using pid file directory: /Volumes/Users/sven/.god/pids
I [2011-03-27 22:49:15] INFO: Started on drbunix:///tmp/god.17165.sock
I [2011-03-27 22:49:15] INFO: resque-0 move 'unmonitored' to 'init'
I [2011-03-27 22:49:15] INFO: resque-0 moved 'unmonitored' to 'init'
I [2011-03-27 22:49:15] INFO: resque-0 [trigger] process is not running (ProcessRunning)
I [2011-03-27 22:49:15] INFO: resque-0 move 'init' to 'start'
I [2011-03-27 22:49:15] INFO: resque-0 start: cd /Volumes/Users/sven/Development/projects/travis && rake resque:work
I [2011-03-27 22:49:15] INFO: resque-0 moved 'init' to 'start'
I [2011-03-27 22:49:15] INFO: resque-0 [trigger] process is running (ProcessRunning)
I [2011-03-27 22:49:15] INFO: resque-0 move 'start' to 'up'
I [2011-03-27 22:49:15] INFO: resque-0 moved 'start' to 'up'
I [2011-03-27 22:49:15] INFO: resque-0 [ok] memory within bounds [784kb] (MemoryUsage)
I [2011-03-27 22:49:15] INFO: resque-0 [ok] process is running (ProcessRunning)
I [2011-03-27 22:49:45] INFO: resque-0 [ok] memory within bounds [784kb, 784kb] (MemoryUsage)
I [2011-03-27 22:49:45] INFO: resque-0 [ok] process is running (ProcessRunning)
Then I'll get an extra process:
$ ps x | grep resque
7187 ?? Ss 0:00.02 sh -c cd /Volumes/Users/sven/Development/projects/travis && rake resque:work
7188 ?? S 0:05.11 resque-1.13.0: Waiting for builds
7183 s001 S+ 0:01.18 /Volumes/Users/sven/.rvm/rubies/ruby-1.8.7-p302/bin/ruby /Volumes/Users/sven/.rvm/gems/ruby-1.8.7-p302/bin/god -c config/resque.god -D
God only seems to log the pid of the first one:
$ cat ~/.god/pids/resque-0.pid
7187
When I then stop the resque watch via god:
$ god stop resque
Sending 'stop' command
The following watches were affected:
resque-0
God gives this log output:
I [2011-03-27 22:51:22] INFO: resque-0 stop: default lambda killer
I [2011-03-27 22:51:22] INFO: resque-0 sent SIGTERM
I [2011-03-27 22:51:23] INFO: resque-0 process stopped
I [2011-03-27 22:51:23] INFO: resque-0 move 'up' to 'unmonitored'
I [2011-03-27 22:51:23] INFO: resque-0 moved 'up' to 'unmonitored'
But it does not actually terminate both of the processes, leaving the actual worker process alive:
$ ps x | grep resque
6864 ?? S 0:05.15 resque-1.13.0: Waiting for builds
6858 s001 S+ 0:01.36 /Volumes/Users/sven/.rvm/rubies/ruby-1.8.7-p302/bin/ruby /Volumes/Users/sven/.rvm/gems/ruby-1.8.7-p302/bin/god -c config/resque.god -D
You need to tell god to use pid file generated by rescue and set pid file
w.env = {'PIDFILE' => '/path/to/resque.pid'}
w.pid_file = '/path/to/resque.pid'
env will tell rescue to write pid file, and pid_file will tell god to use it
also as svenfuchs noted it should be enough to set only proper env:
w.env = { 'PIDFILE' => "/home/travis/.god/pids/#{w.name}.pid" }
where /home/travis/.god/pids is the default pids directory
I might be a little late to the party here but we had the same issue on our side. We were using
rvm 2.1.0# do bundle exec rake environment resque:work
which caused the multiple processes. According to our sysops guy this is due to the usage of rvm do which we ended up replacing with
/path/to/rvm/gems/ruby-2.1.0/wrappers/bundle exec rake environment resque:work
This allowed god to work as expected without the need to specify the pid file.

Resources