Capistrano and deployment of a website from Github - deployment

So, I had what I thought was a fairly simple Capistrano use case: I want to deploy a PHP site from Github. But I'm running into a lot of problems. When I run cap deploy, Capistrano is able to clone the Github repo (the deploy:update_code step), but then in the deploy:finalize_update step it says
executing "rm -rf /var/www/sitename.com/releases/20100611144519/log /var/www/sitename.com/releases/20100611144519/public/system /var/www/sitename.com/releases/20100611144519/tmp/pids &&\\\n mkdir -p /var/www/sitename.com/releases/20100611144519/public &&\\\n mkdir -p /var/www/sitename.com/releases/20100611144519/tmp &&\\\n ln -s /var/www/sitename.com/shared/log /var/www/sitename.com/releases/20100611144519/log &&\\\n ln -s /var/www/sitename.com/shared/system /var/www/sitename.com/releases/20100611144519/public/system &&\\\n ln -s /var/www/sitename.com/shared/pids /var/www/sitename.com/releases/20100611144519/tmp/pids"
followed by
executing "find /var/www/sitename.com/releases/20100611144519/public/images /var/www/sitename.com/releases/20100611144519/public/stylesheets /var/www/sitename.com/releases/20100611144519/public/javascripts -exec touch -t 201006111445.23 {} ';'; true"
I don't really understand what's going on here. It then gives an error:
*** [err :: sitename.com] find: `/var/www/sitename.com/releases/20100611144519/public/images': No such file or directory
and another error for each of the stylesheets and javascripts directories.
What's going on? I realize that Capistrano is primarily for deploying Rails and other Ruby apps, but I'm using the capistrano-php gem. I'd appreciate any help.

Capistrano default behavior is to 'touch' all assets files. (To make sure that any cache get the deployment date). Assets are images, stylesheets, etc.
If your PHP application is not using these directories, capistrano complains in such an ugly way.
To disable asset timestamps updates, simply add:
set :normalize_asset_timestamps, false
to your deploy.rb

Related

How to install Argo CLI?

I am trying to install Argo CLI by following this (https://github.com/argoproj/argo-workflows/releases) documentation.
# Download the binary
curl -sLO https://github.com/argoproj/argo/releases/download/v3.1.3/argo-linux-amd64.gz
# Unzip
gunzip argo-linux-amd64.gz
# Make binary executable
chmod +x argo-linux-amd64
# Move binary to path
mv ./argo-linux-amd64 /usr/local/bin/argo
# Test installation
argo version
The above instructions are not working. So, I followed the answer to this (How to update Argo CLI?) question.
curl -sLO https://github.com/argoproj/argo/releases/download/v2.12.0-rc2/argo-linux-amd64
chmod +x argo-linux-amd64
./argo-linux-amd64
But I am getting the following error:
./argo-linux-amd64: line 1: Not: command not found
I also tried moving the argo-linux-amd64 binary to /usr/local/bin/argo but still getting the same error (as expected).
Is there any solution to this?
Thank you.
The download links on the Releases page are incorrect. Try this one:
curl -sLO https://github.com/argoproj/argo-workflows/releases/download/v3.1.3/argo-linux-amd64.gz
I've submitted an issue to get the links fixed.

How to install Grafana on Mac

I tied the following steps
cd $GOPATH/src/github.com/grafana/grafana
go run build.go setup
I got the following
Version: 2.5.0-pre1, Linux Version: 2.5.0, Package Iteration: pre1
go get -v github.com/tools/godep
github.com/tools/godep (download)
github.com/tools/godep/Godeps/_workspace/src/github.com/kr/fs
github.com/tools/godep/Godeps/_workspace/src/github.com/pmezard/go-difflib/difflib
github.com/tools/godep/Godeps/_workspace/src/golang.org/x/tools/go/vcs
github.com/tools/godep
go get -v github.com/blang/semver
github.com/blang/semver (download)
github.com/blang/semver
go get -v github.com/mattn/go-sqlite3
go install -v github.com/mattn/go-sqlite3
then i executed
$GOPATH/bin/godep restore
i got no putput but command got executed
then i ran the command
go run build.go build
Version: 2.5.0-pre1, Linux Version: 2.5.0, Package Iteration: pre1
rm -r bin
rm -r Godeps/_workspace/pkg
rm -r Godeps/_workspace/bin
rm -r dist
rm -r tmp
rm -r /Users/skhare/sk/go/pkg/darwin_amd64/github.com/grafana
rm -r ./bin/grafana-server
rm -r ./bin/grafana-server.md5
GOPATH=/Users/skhare/sk/go/src/github.com/grafana/grafana/Godeps/_workspace:/Users/skhare/sk/go
go build -ldflags -w -X main.version '2.5.0-pre1' -X main.commit 'v2.1.2+394- gfb767f5' -X main.buildstamp 1442671169 -o ./bin/grafana-server .
# github.com/grafana/grafana
link: warning: option -X main.version 2.5.0-pre1 may not work in future releases; use -X main.version=2.5.0-pre1
link: warning: option -X main.commit v2.1.2+394-gfb767f5 may not work in future releases; use -X main.commit=v2.1.2+394-gfb767f5
link: warning: option -X main.buildstamp 1442671169 may not work in future releases; use -X main.buildstamp=1442671169
then i executed
npm install
i had to install npm
>npm install -g grunt-cli
/usr/local/bin/grunt -> /usr/local/lib/node_modules/grunt-cli/bin/grunt
grunt-cli#0.1.13 /usr/local/lib/node_modules/grunt-cli
├── resolve#0.3.1
├── nopt#1.0.10 (abbrev#1.0.7)
└── findup-sync#0.1.3 (lodash#2.4.2, glob#3.2.11)
>grunt
Running "jscs:src" (jscs) task
>> 156 files without code style errors.
Running "jshint:source" (jshint) task
✔ No problems
Running "jshint:tests" (jshint) task
✔ No problems
Running "tslint:source" (tslint) task
>> 11 files lint free.
Running "clean:gen" (clean) task
Cleaning public_gen...OK
Running "copy:public_to_gen" (copy) task
Created 122 directories, copied 553 files
Running "less:src" (less) task
File public_gen/css/bootstrap.dark.min.css created.
File public_gen/css/bootstrap.light.min.css created.
File public_gen/css/bootstrap-responsive.min.css created.
Running "concat:cssDark" (concat) task
File public_gen/css/grafana.dark.min.css created.
Running "concat:cssLight" (concat) task
File public_gen/css/grafana.light.min.css created.
Running "typescript:build" (typescript) task
42 files created. js: 14 files, map: 14 files, declaration: 14 files (968ms)
Done, without errors.
>go get github.com/Unknwon/bra
the above command did not give any output, nor an error message
bra run
it says -bash: bra: command not found
i tried to look for the resolution, but i could not find it. Please help
Recompile backend on source change
To rebuild on source change (requires that you executed godep restore)
go get github.com/Unknwon/bra
bra run
Running Grafana Locally
You can run a local instance of Grafana by running:
./bin/grafana-server
You must have missed this step!
go get github.com/Unknwon/bra
You can install Grafana using home brew.
brew update
brew install grafana
This sounds like an issue where Go is just being installed to build something else (for me, it was Grafana). In which case $GOPATH/bin is not in your PATH. $GOPATH/bin/bra should work. It did for me.
I suggest you installing Grafana inside Docker. If you install Docker for Mac, the GUI (Kitematic) will allow you to install grafana as easily as one click. You will just need to create a new container with "+ New" button, search grafana through the exisiting image lists and click "Create"
Docker will download grafana and it will appear in the left sidebar:

Symlinking unicorn_init.sh into /etc/init.d doesn't show with chkconfig --list

I'm symlinking my config/unicorn_init.sh to /etc/init.d/unicorn_project with:
sudo ln -nfs config/unicorn_init.sh /etc/init.d/unicorn_<project>
Afterwards, when I run chkconfig --list my unicorn_ script doesn't show. I'm adding my unicorn script to load my application on server load.
Obviously, this is not allowing me to add my script with:
chkconfig unicorn_<project> on
Any help / advice would be awesome :).
Edit:
Also, when I'm in /etc/init.d/ and run:
sudo service unicorn_project start
It says: "unrecognized service"
I figured this out. There were two things wrong with what I was doing:
1) You have to make sure your unicorn script can play nice with chkconfig by adding the below code below #!/bin/bash. Props to digitalocean's blog for the help.
# chkconfig: 2345 95 20
# description: Controls Unicorn sinatra server
# processname: unicorn
2) I was attempting to symlink the config/unicorn_init.sh file when I was already in the project directory which was creating a dangling symlink (pink colored symlink ~> should be teal) by using a relative path. To fix this, I removed the dangling symlink and provided the absolute path to the unicorn_init.sh file.
To debug this I used ll in the /etc/init.d/ directory to see r,w,x permissions and file types, was running chkconfig --list to see a list of services in /etc/init.d/ and also was trying to run the dangling symlink in my /etc/init.d directory with sudo service unicorn_<project> restart
Hope this helps someone.

Capistrano error tar: This does not look like a tar archive

INFO [050fe961] Running mkdir -p /home/rails/rails-
capistrano/releases/20140114234157 on staging-rails
DEBUG [050fe961] Command: cd /home/rails/rails-capistrano/repo && ( PATH=/opt/ruby/bin:$PATH GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/rails/git-ssh.sh mkdir -p /home/rails/rails-capistrano/releases/20140114234157 )
INFO [050fe961] Finished in 0.142 seconds with exit status 0 (successful).
INFO [2dea2fe5] Running git archive feature/Capistrano | tar -x -C /home/rails/rails-capistrano/releases/20140114234157 on staging-rails
DEBUG [2dea2fe5] Command: cd /home/rails/rails-capistrano/repo && ( PATH=/opt/ruby/bin:$PATH GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/rails/git-ssh.sh git archive feature/Capistrano | tar -x -C /home/rails/rails-capistrano/releases/20140114234157 )
DEBUG [2dea2fe5] fatal: Not a valid object name
DEBUG [2dea2fe5] tar: This does not look like a tar archive
DEBUG [2dea2fe5] tar:
DEBUG [2dea2fe5] Exiting with failure status due to previous errors
I am confused about two things:
Why is Capistrano running git archive here:
git archive feature/Capistrano | tar -x -C /home/rails/rails-capistrano/releases/20140114234157
Why is tar failing?
I had the same issue, until I realized I was pulling the nonexistent branch from git.
Deleting app_name/repo also fixed this issue for me.
This happens when the repo in the server to deploy is messed up. We're talking about the bare git repo that Capistrano by default would put in /var/www/$application/repo (for other people's reference).
In your case it does not have a local feature/Capistrano branch so when running git archive feature/Capistrano nothing is output to that | pipe. To confirm, ssh into the server, cd into /home/rails/rails-capistrano/repo, and run git branch.
It's running git archive as a way to export the selected branch's tree. git archive "writes it out to the standard output" so Capistrano redirects that to tar in order to uncompress the archive immediately into your new release directory.
(Why Capistrano chose this instead of git checkout defeats me.)
tar fails because it's receiving nothing d:
I can think of two possible solutions/ways to troubleshoot:
ssh into the server and manually delete the repo folder (e.g. in your case /home/rails/rails-capistrano/repo) as mentioned by #lugolabs
make sure the server's repo is using the remote you're expecting (ssh in, cd into repo/, and run git remote -v) -- you may just need to update your :repo_url in deploy.rb (and delete the repo/ dir).
I think that folder gets populated via a git pull, so it shouldn't be empty. If you do see it empty the issue is from the git not the tarball.
The issue I had was my capistrano deploy.rb repository URL was set to a different one than that project i was working in. In order to fix this issue, I also had to logon to the server and delete the app_name/repo folder which must have been caching the original bad remote URL.
Whenever I have hit this error it was because the branch specified in my deploy/environment.rb file wasn't checked into git. Do an add / commit / git push origin branch_name and that will likely make things work.
You can set your branch on deploy.rb with:
set :branch, "main"
source
Note: the default branch is master
I'm using Bedrock Roots (wordpress) for development, capistrano for deploys and git flow.
Stumbled upon this error when tried to deploy, while on hotfix/x.x.x branch locally. So I finished current (merged changes to develop branch) and then successfully deployed.

Can't resume "wget --mirror" with --no-clobber (-c -F -B unhelpful)

I started a wget mirror with "wget --mirror [sitename]", and it was
working fine, but accidentally interrupted the process.
I now want to resume the mirror with the following caveats:
If wget has already downloaded a file, I don't want it downloaded
it again. I don't even want wget to check the timestamp: I know the
version I have is "recent enough".
I do want wget to read the files it's already downloaded and
follow links inside those files.
I can use "-nc" for the first point above, but I can't seem to coerce
wget to read through files it's already downloaded.
Things I've tried:
The obvious "wget -c -m" doesn't work, because it wants
to compare timestamps, which requires making at least a HEAD request
to the remote server.
"wget -nc -m" doesn't work, since -m implies -N, and -nc is
incompatible with -N.
"wget -F -nc -r -l inf" is the best I could come up with, but it
still fails. I was hoping "-F" would coerce wget into reading local,
already-downloaded files as HTML, and thus follow links, but this
doesn't appear to happen.
I tried a few other options (like "-c" and "-B [sitename]"), but
nothing works.
How do I get wget to resume this mirror?
Apparently this works:
Solved: Wget error “Can’t timestamp and not clobber old files at the
same time.” Posted on February 4, 2012 While trying to resume a
site-mirror operation I was running through Wget, I ran into the error
“Can’t timestamp and not clobber old files at the same time”. It turns
out that running Wget with the -N and -nc flags set at the same time
can’t happen, so if you want to resume a recursive download with
noclobber you have to disable -N. The -m attribute (for mirroring)
intrinsically sets the -N attribute, so you’ll have to switch from -m
to -r in order to use noclobber as well.
From: http://www.marathon-studios.com/blog/solved-wget-error-cant-timestamp-and-not-clobber-old-files-at-the-same-time/
-m, according to the wget manual is equivalent to this longer series of settings: -r -N -l inf --no-remove-listing. Just use those settings instead of -m, and without -N (timestamping).
Now I'm not sure if there is a way to get wget to download urls from existing html files. There probably is a solution, I know it can take html files as inputs and scrape all the links in them. Perhaps you could use a bash command to concatenate all the html files together into one big file.
I solved this problem by just deleting all the html files, because I didn't mind only redownloading them. But this might not work for everyone's use case.