Capistrano 3 upload hangs - setup-deployment

After upgrading to capistrano 3 and solving a lot of trouble there is one thing I cant get working. The new upload functionality in mij script hangs and capistrano wont continue. My original Capistrano 2.x script was partly created from examples I found on the web.
in my recipe:
task :setup do
desc "Creates shared Config dir, uploads local config files."
on roles(:cake) do
execute "mkdir -p #{shared_path}/Config"
on fetch(:cake_config_files) do |cake_config_file|
on roles(:cake) do
execute "echo a"
upload! "Config/#{cake_config_file}", "#{shared_path}/Config/#{cake_config_file}", :via => :scp
execute "echo b"
end
end
end
end
The output:
INFO [4f52db7e] Running /usr/bin/env mkdir -p /home/user/sites/myapp/test/shared/Config on myapp.nl
DEBUG [4f52db7e] Command: mkdir -p /home/user/sites/myapp/test/shared/Config
INFO [4f52db7e] Finished in 0.601 seconds with exit status 0 (successful).
INFO [69fff539] Running /usr/bin/env echo a on myapp.nl
INFO [de58c44d] Running /usr/bin/env echo a on myapp.nl
INFO [9f635a1a] Running /usr/bin/env echo a on myapp.nl
DEBUG [69fff539] Command: echo a
DEBUG [de58c44d] Command: echo a
DEBUG [9f635a1a] Command: echo a
INFO [69fff539] Finished in 0.058 seconds with exit status 0 (successful).
DEBUG [69fff539] a
INFO [69fff539] Finished in 0.058 seconds with exit status 0 (successful).
INFO [de58c44d] Finished in 0.063 seconds with exit status 0 (successful).
DEBUG [de58c44d] a
INFO [de58c44d] Finished in 0.063 seconds with exit status 0 (successful).
INFO [9f635a1a] Finished in 0.075 seconds with exit status 0 (successful).
DEBUG [9f635a1a] a
INFO [9f635a1a] Finished in 0.075 seconds with exit status 0 (successful).
After this, nothing happens. The script just paused/ hangs. My test to echo a B does't do anything also ;)
note: I tried this with and without ':via => :scp' as argument og upload (in my original script i uses ':via => :scp')

I was struggling with the same issues, when i found out the problem was my Rubinius installation.
Changing to current MRI solved it for me. Kind regards

Related

Openstack Devstack installation error : g-api did not start in ubuntu 18.04

I'm installing openstack using All-In-One Single Machine setup, I run stack.sh script for devstack setup. On starting glance service I'm getting following error on my console:
++:: curl -g -k --noproxy '*' -s -o /dev/null -w '%{http_code}' http://10.10.20.10/image
+:: [[ 503 == 503 ]]
+:: sleep 1
+functions:wait_for_service:485 rval=124
+functions:wait_for_service:490 time_stop wait_for_service
+functions-common:time_stop:2310 local name
+functions-common:time_stop:2311 local end_time
+functions-common:time_stop:2312 local elapsed_time
+functions-common:time_stop:2313 local total
+functions-common:time_stop:2314 local start_time
+functions-common:time_stop:2316 name=wait_for_service
+functions-common:time_stop:2317 start_time=1602763779096
+functions-common:time_stop:2319 [[ -z 1602763779096 ]]
++functions-common:time_stop:2322 date +%s%3N
+functions-common:time_stop:2322 end_time=1602763839214
+functions-common:time_stop:2323 elapsed_time=60118
+functions-common:time_stop:2324 total=569
+functions-common:time_stop:2326 _TIME_START[$name]=
+functions-common:time_stop:2327 _TIME_TOTAL[$name]=60687
+functions:wait_for_service:491 return 124
+lib/glance:start_glance:480 die 480 'g-api did not start'
+functions-common:die:198 local exitcode=0
+functions-common:die:199 set +o xtrace
[Call Trace]
./stack.sh:1306:start_glance
/opt/stack/devstack/lib/glance:480:die
[ERROR] /opt/stack/devstack/lib/glance:480 g-api did not start
Error on exit
World dumping... see /opt/stack/logs/worlddump-2020-10-15-121040.txt for details
neutron-dhcp-agent: no process found
neutron-l3-agent: no process found
neutron-metadata-agent: no process found
neutron-openvswitch-agent: no process found
I also tried to increase timeout duration but then also it failed and also verifyied devstack#g-api.service is in active state. Can someone let me know what is the exect reason behind this issue and how to resolve it.
The only solution is to reload the entire system, including the os

How get daemons' status programmatically using Ruby gem "daemons"

I have a script (myscript.rb) like below:
require 'daemons'
Daemons.run_proc 'myproc', dir_mode: :normal, dir: '/path/to/pids' do
# Daemon code here...
end
So, I can check the daemon's status in console by ruby myscript.rb status.
But I need to show the daemon's status in a web page (Rails), like:
<p>Daemon status: <%= "Daemon status here..." </p>
How can this be done?
The defaut way to do this would really be to call ruby myscript.rb status from your Rails application and parse its output to obtain the desired information.
Alternatively you could also create an Application object itself and call #running? on it.
In my tests seems like "status" command exits with non-zero value when the daemon is not running:
$ ruby myscript.rb status; echo $?
myproc: no instances running
3
$ ruby myscript.rb start
myproc: process with pid 21052 started.
$ ruby myscript.rb status; echo $?
myproc: running [pid 21052]
0
$ ruby myscript.rb stop
myproc: trying to stop process with pid 21052...
myproc: process with pid 21052 successfully stopped.
$ ruby myscript.rb status; echo $?
myproc: no instances running
3
So it is possible to programmatically check the daemon status as below:
require 'open3'
stdin, stdout, stderr, wait_thr = Open3.popen3('ruby', 'myscript.rb', 'status')
if wait_thr.value.to_i == 0
puts "Running"
else
puts "Not running"
end

Run Facebook Flow on a Continuos Integration Meteor application

I have a Meteor application with Circle CI as continuous integration service.
Facebook Flow is running locally with the following .flowconfig:
[ignore]
.*/node_modules/.*
[options]
module.name_mapper='^\/\(.*\)$' -> '<PROJECT_ROOT>/\1'
module.name_mapper='^meteor\/\(.*\):\(.*\)$' -> '<PROJECT_ROOT>/.meteor/local/build/programs/server/packages/\1_\2'
module.name_mapper='^meteor\/\(.*\)$' -> '<PROJECT_ROOT>/.meteor/local/build/programs/server/packages/\1'
In CI I get errors like:
client/main.jsx:4
4: import { Meteor } from 'meteor/meteor';
^^^^^^^^^^^^^^^ meteor/meteor. Required module not found
Flow seems not to find my modules. The rewrite rules do not apply. With SSH access to Circle CI I found ot that the <PROJECT_ROOT>/.meteor/local directory is not present.
Once I run meteor on the CI machine the directory will appear.
Problem: If I run meteor the Meteor server will start up and my test will time out.
As far as I see I need to either
Adapt my .flowconfig or
Find a way to get Meteor to create the directory without running meteor or
Find a way to kill the meteor process once the server is running.
I went with the third option:
bbaja42 shared a script that saves the output of a program and terminates the program once a keyword is reached.
Adapted to my case I have two files:
ci-tests.sh
#!/bin/sh
# Check if the output directory exits. Flow needs the modules there.
if [ ! -d ".meteor/local/build/programs/server/packages" ]; then
echo "Meteor build directory does not exist. Starting Meteor."
# Run Meteor so the output directory is built.
./build-and-kill-meteor.sh
else
echo "Meteor build directory exists"
fi
./node_modules/.bin/flow --json
if [ $? -ne 0 ] ; then
exit 1
fi
build-and-kill-meteor.sh
#!/bin/bash
OUTPUT=/tmp/meteor-launch.log
PROGRAM=meteor
$PROGRAM > $OUTPUT &
PID=$!
echo Program is running under pid: $PID
#Every 10 seconds, check requirements
while true; do
tail -1 $OUTPUT
grep "App running at: http://localhost" $OUTPUT
if [ $? -eq 0 ] ; then
break
fi
sleep 10
done
kill $PID || echo "Killing process with pid $PID failed, try manual kill with -9 argument"
I ran into the same issue and came up with my own derivation based on the OP's answer. I run this script on every CI build to ensure that Meteor will always install any new atmosphere packages that I'm shipping with.
#!/bin/bash
# Install meteor
if [ -d ~/.meteor ]; then sudo ln -s ~/.meteor/meteor /usr/local/bin/meteor; fi
if [ ! -e $HOME/.meteor/meteor ]; then curl https://install.meteor.com | sh; fi
OUTPUT=/tmp/meteor-launch.log
PROGRAM=meteor
$PROGRAM > $OUTPUT &
PID=$!
echo Program is running under pid: $PID
# Start meteor to install atmosphere packages
while true; do
tail -1 $OUTPUT
grep "Your application is crashing." $OUTPUT
# Cancel the program once meteor has started
if [ $? -eq 0 ] ; then
break
fi
sleep 10
done
kill $PID || echo "Killing process with pid $PID failed, try manual kill with -9 argument."

Capistrano/Git not recognising checkout -B flag unless logged in via ssh

I'm trying to use capistrano to deploy a wordpress site to my account on dreamhost.
For the most part capistrano seems to be working. Here's the output from cap dev git:check
$ cap dev git:check
INFO [1cd5c6b7] Running /usr/bin/env mkdir -p /home/parisstilton/tmp/theparisstilton.com/ on theparisstilton.com
DEBUG [1cd5c6b7] Command: /usr/bin/env mkdir -p /home/parisstilton/tmp/theparisstilton.com/
INFO [1cd5c6b7] Finished in 1.895 seconds with exit status 0 (successful).
DEBUG Uploading /home/parisstilton/tmp/theparisstilton.com/git-ssh.sh 0.0%
INFO Uploading /home/parisstilton/tmp/theparisstilton.com/git-ssh.sh 100.0%
INFO [4ede30ed] Running /usr/bin/env chmod +x /home/parisstilton/tmp/theparisstilton.com/git-ssh.sh on theparisstilton.com
DEBUG [4ede30ed] Command: /usr/bin/env chmod +x /home/parisstilton/tmp/theparisstilton.com/git-ssh.sh
INFO [4ede30ed] Finished in 0.317 seconds with exit status 0 (successful).
INFO [8d47d9d7] Running /usr/bin/env mkdir -p /home/parisstilton/tmp/theparisstilton.com/ on theparisstilton.com
DEBUG [8d47d9d7] Command: /usr/bin/env mkdir -p /home/parisstilton/tmp/theparisstilton.com/
INFO [8d47d9d7] Finished in 1.668 seconds with exit status 0 (successful).
DEBUG Uploading /home/parisstilton/tmp/theparisstilton.com/git-ssh.sh 0.0%
INFO Uploading /home/parisstilton/tmp/theparisstilton.com/git-ssh.sh 100.0%
INFO [1aacdb9a] Running /usr/bin/env chmod +x /home/parisstilton/tmp/theparisstilton.com/git-ssh.sh on theparisstilton.com
DEBUG [1aacdb9a] Command: /usr/bin/env chmod +x /home/parisstilton/tmp/theparisstilton.com/git-ssh.sh
INFO [1aacdb9a] Finished in 0.266 seconds with exit status 0 (successful).
DEBUG [bd5cfd74] Running /usr/bin/env git ls-remote git#bitbucket.org:sentur/partisstilton.git on theparisstilton.com
DEBUG [bd5cfd74] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/home/parisstilton/tmp/theparisstilton.com/git-ssh.sh /usr/bin/env git ls-remote git#bitbucket.org:sentur/partisstilton.git )
DEBUG [bd5cfd74] 5cadb90b1a5d4bbe59c2eb8e3f3e108f49b98fd0 HEAD
DEBUG [bd5cfd74] 9451025272b2a594ffc2af259bfce50c66ff15fc refs/heads/dev
DEBUG [bd5cfd74] 5cadb90b1a5d4bbe59c2eb8e3f3e108f49b98fd0 refs/heads/master
DEBUG [bd5cfd74] Finished in 2.722 seconds with exit status 0 (successful).
DEBUG [baacc1b3] Running /usr/bin/env git ls-remote git#bitbucket.org:sentur/partisstilton.git on theparisstilton.com
DEBUG [baacc1b3] Command: ( GIT_ASKPASS=/bin/echo GIT_SSH=/home/parisstilton/tmp/theparisstilton.com/git-ssh.sh /usr/bin/env git ls-remote git#bitbucket.org:sentur/partisstilton.git )
DEBUG [baacc1b3] 5cadb90b1a5d4bbe59c2eb8e3f3e108f49b98fd0 HEAD
DEBUG [baacc1b3] 9451025272b2a594ffc2af259bfce50c66ff15fc refs/heads/dev
DEBUG [baacc1b3] 5cadb90b1a5d4bbe59c2eb8e3f3e108f49b98fd0 refs/heads/master
DEBUG [baacc1b3] Finished in 2.724 seconds with exit status 0 (successful).
When I deploy using the following code bundle exec cap dev deploy ( http://pastebin.com/fCWRjEyv ), capistrano fails at
DEBUG [e6f95da6] Command: cd /home/parisstilton/dev.theparisstilton.com/repo && ( GIT_ASKPASS=/bin/echo GIT_SSH=/home/parisstilton/tmp/theparisstilton.com/git-ssh.sh /usr/bin/env git checkout -B 20140806215353 origin/dev )
DEBUG [e6f95da6] error: unknown switch `B'
DEBUG [e6f95da6] usage: git checkout [options] <branch>
DEBUG [e6f95da6] or: git checkout [options] [<branch>] -- <file>...
However if I ssh into the dreamhost server and run the same command it works fine recognising the git checkout -B flag. I suspect that this may be because I have installed a more recent version of git (2.0.4) in my ~/packages/bin/ which is in my $PATH. Where as the default git on Dreamhost is git version 1.7.2.5.
[beehive]$ cd /home/parisstilton/dev.theparisstilton.com/repo && ( GIT_ASKPASS=/bin/echo GIT_SSH=/home/parisstilton/tmp/theparisstilton.com/git-ssh.sh /usr/bin/env git checkout -B 20140806215353 origin/dev )
Branch 20140806215353 set up to track remote branch dev from origin.
Switched to a new branch '20140806215353'
I managed to find a simple solution (though not sure if it's right, it works for me).
Editing the ~/.bashrc file to update $PATH as this is run by non-interactive shells where as ~/.bash_profile where I had originally updated my $PATH, is only run by bash on interactive shell login.
So here's the code.
$nano ~/.bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
#add ~/packages/bin installed apps/git to $PATH
export PATH=~/packages/bin:$PATH

Baffling Debian installation script: service starts but then quits mysteriously - Why?

I've been struggling with this one for a while and I'm thoroughly baffled.
I have this postinst Debian script that is supposed to start a service once installation (of the service executable) is complete. As best I can tell, the service does start successfully, but it then immediately and mysteriously quits. Restarting the service from the command-line works fine once Synaptic concludes.
I tried writing a dummy package to verify this. The dummy package installs /etc/init/service-dummy.conf and a symbolic link to that file, named /etc/init.d/service-dummy (just like the original service). The contents of service-dummy.conf are the same as service.conf. The dummy starts the service...and then the service keeps on running. So I can't even reproduce my problem!
The postinst script does this:
#!/bin/sh
set -e
case "$1" in
configure)
# (instructions which config, make and install the freshly installed source code)
ldconfig
echo "Install concluded"
if [ -e "/etc/init/service-dummy.conf" ]; then
echo "Starting service-dummy root service" | tee service.log
service service-dummy restart | tee --append service.log
else
echo "service-dummy.conf not installed"
fi
echo "Postinst complete"
;;
*)
echo "postinst called with unknown argument '$1'" >&2
;;
esac
# exit 1 to ensure installer stalls
exit 1
Synaptic displays the log:
...
Starting service-dummy root service
stop: Unknown instance:
service-dummy start/running, process 9207
Postinst complete
dpkg: error processing service-dummy (--configure):
subprocess installed post-installation script returned error exit status 1
...
It's as if upstart needed to be refreshed?
I tried more things and then I did get it to work, sort of: I try starting the service, then abort the script with an exit 1, and when the script runs a second time (postinst, same parameters, so I detect the second run otherwise), I start the service again, and this time it sticks.
A key clue is in the log:
Postinst complete (aborting script)
dpkg: error processing service-dummy (--configure):
subprocess installed post-installation script returned error exit status 1
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
Errors were encountered while processing:
service-dummy
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install. Trying to recover:
Setting up service-dummy ...
service-dummy postinst configure
Starting service-dummy a second time
stop: Unknown instance:
service-dummy start/running, process 4034
Postinst complete (aborting script recovery attempt)
So I guess my question now becomes:
How do I force ldconfig to not defer its processing?
Found the right clue here: http://lists.debian.org/debian-glibc/2008/07/msg00169.html
Turns out apt-get temporarily prevents use of ldconfig by replacing it with something else. The solution to my problem is to very simply call ldconfig.real instead of ldconfig in the script.

Resources