Capistrano - mark deployment as failed - deployment

I'm using Capistrano 3.
I want to trigger a webhook to a external service, when my deployment fails.
It's a matter of calling a method I have already defined, let's say it's called mark_failed.
How I can ensure the method is always called when the deployment fails, for whatever reason, except aborting it via CTRL+C ?
Tried fiddling around with
rescue SystemExit, Interrupt and rescue StandardError
I have no clue where to put my method call the way it will be called reliably.
Any clues ?

I would suggest using at_exit.
at_exit do
mark_failed if $!
end
raise "Something is wrong!"

Related

Jfrog-Pipelines - Kill multiple runs of a pipeline branch via REST

I want to kill hundreds of pipeline runs of specific pipeline and specific branch (without deleting either of them). Any idea how I can do it?
This can be done via a script which first calls all the runs of pipeline with
GET /runs?pipelineIds=&statusCodes=
and then cancels them one by one using:
POST /runs/:runId/cancel
Status codes of incomplete runs are 4000, 4001, 4005, 4015, 4016, 4022
Refer documentation for more details

No error when stopping non existing service with chef

Im new to chef and trying to understand why this code does not return any error while if i do the same with 'start' i will get an error for such service does not exist.
service 'non-existing-service' do
action :stop
end
# chef-apply test.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
* service[non-existing-service] action stop (up to date)
Don't know which plattform you are running on if you are running on Windows it should at least log
Chef::Log.debug "#{#new_resource} does not exist - nothing to do"
given that you have debug as log level.
You could argue this is the wrong behaviour, but if the service dose not exist it for sure isen't running.
Source code
https://github.com/chef/chef/blob/master/lib/chef/provider/service/windows.rb#L147
If you are getting one of the variants of the init.d provider, they default to getting the current status of a service by grepping the process table. Because Chef does its own idempotence checks internally before calling the provider's stop method, it would see there is no such process in the table and assume it was already stopped.

Upstart problems with clone using CLONE_NEWPID and expect fork

I have a binary which looks something like the following:
int RealMain() {
... runs forever ...
}
int main() {
clone(RealMain, ..., CLONE_NEWPID /*clone flags*/, ...);
_exit(0);
}
The idea is to launch a process which launches the actual process via clone() and exits. The reason for this model is the "CLONE_NEWPID" flag. I need the app to run in a separate PID namespace. Therefore, the actual application process needs to be created via clone using the CLONE_NEWPID flag.
When I launch this binary from command line, everything works well. But when I launch it through Upstart, the clone() fails with errno set to EPERM and the new PID namespace is never created. I'm using "expect fork" in the Upstart config because of the clone() call above. That way I can associate liveness to the lifetime of the child process executing RealMain().
expect fork
respawn
I'm wondering if there is some bad interaction between the implementation of "expect fork" and the use of CLONE_NEWPID which creates a new PID namespace. I found the following source about "expect fork" and ptrace issues, but haven't found someone else reporting a problem with CLONE_NEWPID:
https://blueprints.launchpad.net/ubuntu/+spec/foundations-q-upstart-overcome-ptrace-limitations
Thanks

Unicorn restart issue with capistrano

We're deploying with cap and using a script that send USR2 to the unicorn process to reload and it usually works but every once in a while it will fail. When that happens looking in the unicorn log reveals that it's looking for a Gemfile in an old release directory that no longer exists.
Exception :
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/definition.rb:14:in `build': /var/www/railsapps/inventory/releases/20111128233407/Gemfile not found (Bundler::GemfileNotFound)
To clarify that's not the current release but an older one that's since been removed.
When it works it does seem to work correctly - ie it does pickup the new code - so I don't think it's somehow stuck referring to the old release.
Any ideas?
In your unicorn.rb add the before_exec block
current_path = "/var/www/html/my project/current"
before_exec do |server|
ENV['BUNDLE_GEMFILE'] = "#{current_path}/Gemfile"
end
Read more about it here http://blog.willj.net/2011/08/02/fixing-the-gemfile-not-found-bundlergemfilenotfound-error/
You should set the BUNDLE_GEMFILE environment variable before you start the server, point it at current/Gemfile.

Coldfusion FarCry CMS error on start up after server reboot

We're using Farcry CMS which runs on top of ColdFusion. Site was running fine but we are getting this error message after a web server reboot.
"Failed to initialise core type: dmHTML.cfc"
"Parameter 1 of function IsDefined, which is now application.stcoapi.dmHTML.stWebskins.Copy of displayPageCalculatorSelector.displayname, must be a syntactically valid variable name."
Really not sure where to start, could anyone suggest a strategy for troubleshooting this type of error.
Looks like you have a file called "Copy of displayPageCalculatorSelector.cfm" in your dmHTML webskin folder.
Remove this file is the best option.
Or rename it and remove the spaces, e.g. "Copy_of_displayPageCalculatorSelector.cfm"