My capistrano release appears to be "sucked", since no matter how many cap production deploys I send, the /current folder is generated over and over again pointing to the same folder.
# Trying to open /current with FTP Sync
Command: CWD /public_html/storekey-demo/releases/20180813141339
Response: 550 /public_html/storekey-demo/releases/20180813141339: No such file or directory
Error: Failed to retrieve directory listing
Even after deleting the /current folder, the /releases folder, the /repo folder, the /temp folder, and the revisions.log file, and running capistrano again, the symlink is created pointing to the same folder. I think I've tried everything I can think of.
This is my deploy.rb file
lock "~> 3.11.0"
set :application, "storekey_demo" # don't use "-"
set :repo_url, "git#gitlab.com: xxxxxxxxxxx .git"
set :deploy_to, "/home/u0000000/public_html/storekey-demo"
set :tmp_dir, '/home/u0000000/public_html/tmp'
namespace :deploy do
desc "Build"
after :updated, :build do
on roles(:web) do
within release_path do
execute :composer, "install --no-dev --quiet --optimize-autoloader"
end
end
end
end
namespace :deploy do
desc "Copy Env"
after :finished, :copy do
on roles(:all) do
upload! "production.env", "#{current_path}/.env"
end
end
end
This is my deploy log, as you can see there are no errors
> cap production deploy
00:00 git:wrapper
01 mkdir -p /home/u000000000/public_html/tmp
✔ 01 u000000000#185.201.11.23 7.806s
Uploading /home/u000000000/public_html/tmp/git-ssh-storekey_demo-production-francisco.sh 100.0%
02 chmod 700 /home/u000000000/public_html/tmp/git-ssh-storekey_demo-production-francisco.sh
✔ 02 u000000000#185.201.11.23 0.445s
00:09 git:check
01 git ls-remote git#gitlab.com: xxxxxx .git HEAD
01 75bb7ded165efb968f00d29808b0673d7517aa41 HEAD
✔ 01 u000000000#185.201.11.23 1.438s
00:10 deploy:check:directories
01 mkdir -p /home/u000000000/public_html/storekey-demo/shared /home/u000000000/public_html/storekey-demo/releases
✔ 01 u000000000#185.201.11.23 0.399s
00:12 git:clone
The repository mirror is at /home/u000000000/public_html/storekey-demo/repo
00:12 git:update
01 git remote set-url origin git#gitlab.com: xxxxxxx .git
✔ 01 u000000000#185.201.11.23 0.465s
02 git remote update --prune
02 Fetching origin
✔ 02 u000000000#185.201.11.23 1.537s
00:15 git:create_release
01 mkdir -p /home/u000000000/public_html/storekey-demo/releases/20180813165948
✔ 01 u000000000#185.201.11.23 0.455s
02 git archive master | /usr/bin/env tar -x -f - -C /home/u000000000/public_html/storekey-demo/releases/20180813165948
✔ 02 u000000000#185.201.11.23 6.387s
00:23 deploy:set_current_revision
01 echo "75bb7ded165efb968f00d29808b0673d7517aa41" > REVISION
✔ 01 u000000000#185.201.11.23 0.443s
00:24 deploy:build
01 composer install --no-dev --quiet --optimize-autoloader
✔ 01 u000000000#185.201.11.23 6.045s
00:30 deploy:symlink:release
01 ln -s /home/u000000000/public_html/storekey-demo/releases/20180813165948 /home/u000000000/public_html/storekey-demo/releases/current
✔ 01 u000000000#185.201.11.23 25.267s
02 mv /home/u000000000/public_html/storekey-demo/releases/current /home/u000000000/public_html/storekey-demo
✔ 02 u000000000#185.201.11.23 0.421s
00:56 deploy:cleanup
Keeping 5 of 6 deployed releases on 185.201.11.23
01 rm -rf /home/u000000000/public_html/storekey-demo/releases/20180813164636
✔ 01 u000000000#185.201.11.23 0.543s
00:58 deploy:log_revision
01 echo "Branch master (at 75bb7ded165efb968f00d29808b0673d7517aa41) deployed as release 20180813165948 by francisco" >> /home/u000000000/publ…
✔ 01 u000000000#185.201.11.23 0.530s
00:59 deploy:copy
Uploading production.env 100.0%
It seems like the problem was in FileZilla itself, and not in capistrano.
I entered through the SSH console in my server and deleted the /current symlink, then created it again pointing to the last build, and run capistrano production deploy. The problem is fixed and changes are being deployed correctly, but FireZilla is still not recognizing the symlink correctly.
Related
I have an empty Rails application working on my development machine.
I have been following the tutorial at https://gorails.com/deploy/ubuntu/20.04 in order to deploy it to a new DigitalOcean ubuntu 20.04 droplet.
I work my way through the entire entire tutorial and get to the step where I run the deploy:
ThinkPad-T570:~/rails/rbwapp$ cap production deploy
00:00 git:wrapper
01 mkdir -p /tmp
✔ 01 rbw#64.225.88.53 0.110s
Uploading /tmp/git-ssh-rbwapp-production-rbw.sh 100.0%
02 chmod 700 /tmp/git-ssh-rbwapp-production-rbw.sh
✔ 02 rbw#64.225.88.53 0.063s
00:00 git:check
01 git ls-remote git#github.com:rwaddington/rbwapp.git HEAD
01 0d717f41d83befe63856ddf6cfdf4d808519a1dc HEAD
✔ 01 rbw#64.225.88.53 0.795s
00:01 deploy:check:directories
01 mkdir -p /home/rbw/rails/rbwapp/shared /home/rbw/rails/rbwapp/releases
✔ 01 rbw#64.225.88.53 0.059s
00:01 deploy:check:linked_dirs
01 mkdir -p /home/rbw/rails/rbwapp/shared/log /home/rbw/rails/rbwapp/shared/tmp/pids /home/rbw/rails/rbwapp/shared/tmp/cache /…
✔ 01 rbw#64.225.88.53 0.100s
00:01 git:clone
The repository mirror is at /home/rbw/rails/rbwapp/repo
00:01 git:update
01 git remote set-url origin git#github.com:rwaddington/rbwapp.git
✔ 01 rbw#64.225.88.53 0.107s
02 git remote update --prune
02 Fetching origin
✔ 02 rbw#64.225.88.53 0.820s
00:02 git:create_release
01 mkdir -p /home/rbw/rails/rbwapp/releases/20200828170348
✔ 01 rbw#64.225.88.53 0.106s
02 git archive master | /usr/bin/env tar -x -f - -C /home/rbw/rails/rbwapp/releases/20200828170348
✔ 02 rbw#64.225.88.53 0.074s
00:03 deploy:set_current_revision
01 echo "0d717f41d83befe63856ddf6cfdf4d808519a1dc" > REVISION
✔ 01 rbw#64.225.88.53 0.061s
00:03 deploy:symlink:linked_dirs
01 mkdir -p /home/rbw/rails/rbwapp/releases/20200828170348 /home/rbw/rails/rbwapp/releases/20200828170348/tmp /home/rbw/rails/…
✔ 01 rbw#64.225.88.53 0.102s
02 rm -rf /home/rbw/rails/rbwapp/releases/20200828170348/log
✔ 02 rbw#64.225.88.53 0.060s
03 ln -s /home/rbw/rails/rbwapp/shared/log /home/rbw/rails/rbwapp/releases/20200828170348/log
✔ 03 rbw#64.225.88.53 0.104s
04 ln -s /home/rbw/rails/rbwapp/shared/tmp/pids /home/rbw/rails/rbwapp/releases/20200828170348/tmp/pids
✔ 04 rbw#64.225.88.53 0.055s
05 ln -s /home/rbw/rails/rbwapp/shared/tmp/cache /home/rbw/rails/rbwapp/releases/20200828170348/tmp/cache
✔ 05 rbw#64.225.88.53 0.107s
06 ln -s /home/rbw/rails/rbwapp/shared/tmp/sockets /home/rbw/rails/rbwapp/releases/20200828170348/tmp/sockets
✔ 06 rbw#64.225.88.53 0.065s
07 ln -s /home/rbw/rails/rbwapp/shared/vendor/bundle /home/rbw/rails/rbwapp/releases/20200828170348/vendor/bundle
✔ 07 rbw#64.225.88.53 0.105s
08 ln -s /home/rbw/rails/rbwapp/shared/.bundle /home/rbw/rails/rbwapp/releases/20200828170348/.bundle
✔ 08 rbw#64.225.88.53 0.061s
09 ln -s /home/rbw/rails/rbwapp/shared/public/system /home/rbw/rails/rbwapp/releases/20200828170348/public/system
✔ 09 rbw#64.225.88.53 0.106s
10 ln -s /home/rbw/rails/rbwapp/shared/public/uploads /home/rbw/rails/rbwapp/releases/20200828170348/public/uploads
✔ 10 rbw#64.225.88.53 0.063s
11 ln -s /home/rbw/rails/rbwapp/shared/public/assets /home/rbw/rails/rbwapp/releases/20200828170348/public/assets
✔ 11 rbw#64.225.88.53 0.105s
00:05 bundler:config
01 $HOME/.rbenv/bin/rbenv exec bundle config --local deployment true
✔ 01 rbw#64.225.88.53 0.389s
02 $HOME/.rbenv/bin/rbenv exec bundle config --local path /home/rbw/rails/rbwapp/shared/bundle
✔ 02 rbw#64.225.88.53 0.514s
03 $HOME/.rbenv/bin/rbenv exec bundle config --local without development:test
✔ 03 rbw#64.225.88.53 0.607s
00:07 bundler:install
The Gemfile's dependencies are satisfied, skipping installation
00:08 deploy:assets:precompile
01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
01 yarn install v1.22.5
01 [1/4] Resolving packages...
01 [2/4] Fetching packages...
01 info fsevents#2.1.3: The platform "linux" is incompatible with this module.
01 info "fsevents#2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
01 info fsevents#1.2.13: The platform "linux" is incompatible with this module.
01 info "fsevents#1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
01 [3/4] Linking dependencies...
01 [4/4] Building fresh packages...
01 Done in 13.85s.
01 yarn install v1.22.5
01 [1/4] Resolving packages...
01 [2/4] Fetching packages...
01 info fsevents#2.1.3: The platform "linux" is incompatible with this module.
01 info "fsevents#2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
01 info fsevents#1.2.13: The platform "linux" is incompatible with this module.
01 info "fsevents#1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
01 [3/4] Linking dependencies...
01 [4/4] Building fresh packages...
01 Done in 7.12s.
01 Compiling...
01 Compiled all packs in /home/rbw/rails/rbwapp/releases/20200828170348/public/packs
01 Hash: 666d45eeef50ba415ec8
01 Version: webpack 4.44.1
01 Time: 9726ms
01 Built at: 08/28/2020 5:04:31 PM
01 Asset Size Chunks Chunk Names
01 js/application-dd6e88065a32b23f8e21.js 69.3 KiB 0 [emitted] [immutable] application
01 js/application-dd6e88065a32b23f8e21.js.br 15.3 KiB [emitted]
01 js/application-dd6e88065a32b23f8e21.js.gz 17.7 KiB [emitted]
01 js/application-dd6e88065a32b23f8e21.js.map 205 KiB 0 [emitted] [dev] application
01 js/application-dd6e88065a32b23f8e21.js.map.br 44 KiB [emitted]
01 js/application-dd6e88065a32b23f8e21.js.map.gz 51 KiB [emitted]
01 manifest.json 364 bytes [emitted]
01 manifest.json.br 129 bytes [emitted]
01 manifest.json.gz 142 bytes [emitted]
01 Entrypoint application = js/application-dd6e88065a32b23f8e21.js js/application-dd6e88065a32b23f8e21.js.map
01 [0] (webpack)/buildin/module.js 552 bytes {0} [built]
01 [1] ./app/javascript/packs/application.js 742 bytes {0} [built]
01 [5] ./app/javascript/channels/index.js 205 bytes {0} [built]
01 [6] ./app/javascript/channels sync _channel\.js$ 160 bytes {0} [built]
01 + 3 hidden modules
01
✔ 01 rbw#64.225.88.53 36.283s
00:44 deploy:assets:backup_manifest
01 mkdir -p /home/rbw/rails/rbwapp/releases/20200828170348/assets_manifest_backup
✔ 01 rbw#64.225.88.53 0.107s
02 cp /home/rbw/rails/rbwapp/releases/20200828170348/public/assets/.sprockets-manifest-36bf47d96af8c04d2269f7a55275b52a.json /…
✔ 02 rbw#64.225.88.53 0.064s
00:44 deploy:migrate
[deploy:migrate] Run `rake db:migrate`
00:44 deploy:migrating
01 $HOME/.rbenv/bin/rbenv exec bundle exec rake db:migrate
01 rake aborted!
01 ActiveRecord::NoDatabaseError: FATAL: database "rails/rbwapp" does not exist
... stackdump omitted ...
The error is correct in the sense that database "rails/rbwapp" doesn't exist, but it's also not supposed to. It should be looking for "rbwapp_production" (which does exist)
I'm stuck. Any suggestions greatly appreciated...
I noticed that a GitHub repository has zero contributors with obvious commits. How is this possible?
The committer email is not associated with any GitHub account. By picking a random commit, add adding the .patch suffix you can see this:
https://github.com/atomiks/reddit-user-analyser/commit/508b9f745dcfd9117367fa88e982bb739ecac616.patch
From 508b9f745dcfd9117367fa88e982bb739ecac616 Mon Sep 17 00:00:00 2001
From: atomiks <na#gmail.com>
Date: Wed, 22 Feb 2017 08:47:53 +1100
Subject: [PATCH] separate comments and submissions timeframes
...
The na#gmail.com is probably not associated with any GitHub account.
You can create such a repository following these steps:
# Create the Git repo locally
$ mkdir foo
$ cd foo/
$ git init
Initialized empty Git repository in /.../foo/.git/
# Create some files
$ echo 'foo' > index.js
$ ls
index.js
# Create the commit, but pass an invalid email address
# or one you are sure that is not associated with *any*
# GitHub account
$ git add . -A
$ git commit -m 'Initial' . --author 'foo <fooooooo_or_invalid_email_address_which_is_not_on_github#bar.com>'
[master a34597b] Initial
Author: foo <fooooooo_or_invalid_email_address_which_is_not_on_github#bar.com>
Date: Wed May 31 13:51:19 2017 +0300
1 file changed, 1 insertion(+)
create mode 100644 index.js
# Add the GitHub url
$ git remote add origin git#github.com:IonicaBizau/tmp42.git
# Push the repo
$ git push --all
Counting objects: 3, done.
Writing objects: 100% (3/3), 271 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To github.com:IonicaBizau/tmp42.git
* [new branch] master -> master
Then on the Github repo page you will see:
Clicking on the commit url and adding the .patch suffix (to get the raw information):
From a34597b39da17eb77ab29f686a78b276a3c18376 Mon Sep 17 00:00:00 2001
From: foo <fooooooo_or_invalid_email_address_which_is_not_on_github#bar.com>
Date: Wed, 31 May 2017 13:51:19 +0300
Subject: [PATCH] Initial
---
index.js | 1 +
1 file changed, 1 insertion(+)
create mode 100644 index.js
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..257cc56
--- /dev/null
+++ b/index.js
## -0,0 +1 ##
+foo
I have a simple bash script that makes a call to a git repository on github (/home/user/simple_git.sh):
#!/bin/bash
# Change to the Git repoistory
cd /home/user/git/a_git_repo
remote=$(
git ls-remote -h origin master |
awk '{print $1}'
)
local=$(
git rev-parse HEAD
)
printf "Local : %s\nRemote: %s\n" $local $remote
It gives the following output:
Local : a10dc1d7d30ed67ed1e514a3c1ffc5a824cea14b
Remote: a10dc1d7d30ed67ed1e514a3c1ffc5a824cea14b
git authentication is done via ssh keys - the following is my my .bashrc
# ssh
eval `ssh-agent -s`
ssh-add
The script runs just fine as user as well as with sudo (by preserving the user environment) ie.
~/.simple_git.sh
or
sudo -E ~/simple_git.sh
However, I've still not yet found a way to run the script as a service (/etc/systemd/user/simple_git.service or /etc/systemd/system/simple_git.service)
[Unit]
Description=TestScript
[Service]
Type=simple
ExecStart=/home/user/simple_git.sh
I've tried running the systemctl command with the --user option as well as modifying visudo to include the line
Defaults env_keep += SSH_AUTH_SOCK
but to no avail. Everytime I check the status of the job:
Feb 21 23:16:00 alarmpi systemd[484]: Started TestScript.
Feb 21 23:16:01 alarmpi simple_git.sh[15255]: Permission denied (publickey).
Feb 21 23:16:01 alarmpi simple_git.sh[15255]: fatal: Could not read from remote repository.
Feb 21 23:16:01 alarmpi simple_git.sh[15255]: Please make sure you have the correct access rights
Feb 21 23:16:01 alarmpi simple_git.sh[15255]: and the repository exists.
Feb 21 23:16:01 alarmpi simple_git.sh[15255]: Local : a10dc1d7d30ed67ed1e514a3c1ffc5a824cea14b
Systemd is not running the service with your environment variables from your session. I would recommend you to
Use git using https, which will not require authentication (instead of ssh)
Create an unprotected "deploy key", which will be in standard location (~alarmpi/.ssh/id_rsa), which will get picked up by git automatically without ssh-agent.
At this time (working practise policy) it was not possible to use https to connect to github. While the idea of an unprotected deploy-key is useful I ended up using systemctl --user import-environment (wiki.archlinux.org/index.php/Systemd/User) to mange the issue at this time.
I have a project version-controlled by the Mercurial (project main). The project references (uses) some files from another project (sub) by a symbolic link in the main pointing to a file in sub. The symbolic link is added to the main's repository.
The problem is that Mercurial doesn't detect changes made to the target file at sub, not marking the symlink as 'M' (modified).
The situation is shown in the following example:
Create, init and commit initial repos:
$ mkdir crap
$ cd crap
$ mkdir main sub
$ cd sub
$ nano sub.txt
$ hg init
$ hg add sub.txt
$ cd ../main/
$ nano main.txt
$ ln -s ../sub/sub.txt ./sub.txt
$ ls -la
total 24
drwxrwxr-x 2 ruslan ruslan 4096 Jan 15 12:51 .
drwxrwxr-x 4 ruslan ruslan 4096 Jan 15 12:48 ..
-rw-rw-r-- 1 ruslan ruslan 20 Jan 15 12:51 main.txt
lrwxrwxrwx 1 ruslan ruslan 14 Jan 15 12:51 sub.txt -> ../sub/sub.txt
$ hg init
$ hg add main.txt sub.txt
$ hg commit -m "First"
$ cd ../sub
$ hg commit -m "Sub First"
$ hg status ./sub -A
C sub/sub.txt
$ hg status ./main -A
C main/main.txt
C main/sub.txt
now modify and commit the target in sub:
$ nano ./sub/sub.txt
$ hg status ./sub -A
M sub/sub.txt
$ hg commit ./sub -m "Modified"
$ hg status ./sub -A
C sub/sub.txt
now status of the main shows that the symlink that references the target is not marked as 'M':
$ hg status ./main -A
C main/main.txt
C main/sub.txt
modifying the sub again without the commit shows 'M' in sub but not in main:
$ nano ./sub/sub.txt
$ hg status ./sub
M sub/sub.txt
$ hg status ./main -A
C main/main.txt
C main/sub.txt
How can I properly make Mercurial detect changes in symlinks' targets?
You can't. For security reasons, Mercurial never traverses symbolic links.
You can use a hard link instead by omitting -s parameter when creating with ln.
I recommend appending .hardlink to be explicit and modifying your ls to highlight hardlinks.
On a windows machine I have used same approach using
Link Shell Extension utility; I donated to the author and you should do the same :).
I'm trying to get gitweb setup on a CentOS 6.2 server with git/gitweb 1.7.1 and httpd 2.2.15 installed.
gitweb's default project root (verified in the CGI script) is /var/lib/git, so I've created that and a bare git repository in there:
$ ls -laF /var/lib/git
total 12
drwxrwxr-x. 3 git git 4096 Feb 8 16:37 ./
drwxr-xr-x. 15 root root 4096 Feb 8 14:20 ../
drwxrwxr-x. 7 git git 4096 Feb 8 15:37 foo/
$ git init --bare --shared foo
Initialized empty shared Git repository in /var/lib/git/foo/
$ ls -lF foo
total 32
drwxrwsr-x. 2 git git 4096 Feb 8 17:16 branches/
-rw-rw-r--. 1 git git 126 Feb 8 17:16 config
-rw-rw-r--. 1 git git 73 Feb 8 17:16 description
-rw-rw-r--. 1 git git 23 Feb 8 17:16 HEAD
drwxrwsr-x. 2 git git 4096 Feb 8 17:16 hooks/
drwxrwsr-x. 2 git git 4096 Feb 8 17:16 info/
drwxrwsr-x. 4 git git 4096 Feb 8 17:16 objects/
drwxrwsr-x. 4 git git 4096 Feb 8 17:16 refs/
$ cat foo/HEAD
ref: refs/heads/master
However on viewing http://localhost/git/, I see "404 No projects found".
I've debugged through the script and can see that it's finding /var/lib/git/foo, but Perl's -e operator fails on /var/lib/git/foo/HEAD. At the same place in the file, a backticked call to ls shows that the file is visible there, but I cannot make Perl -e see the file.
Any idea what might be making this fail? This makes no sense to me.
EDIT: note that SELinux extensions on this CentOS box appear to be disabled:
$ sudo sestatus
SELinux status: disabled
EDIT: moving everything from /var/lib/git to /git hasn't helped. I've changed the apache user to have a real shell, logged in as that user, and verified that it has access to all the directories and files in question.
It was in fact SELinux. Even though SELinux reported it was disabled, it was somehow preventing access to some files for CGI scripts running under httpd. Enabling SELinux and setting it to permissive mode, it started working.
This seems highly non-intuitive and frustrates me, but at least it's working.
I'm still thinking it's an issue with permissions... but I could be wrong. Have you ensured that all of the parent directories leading up to your /var/lib/git directory are permission-accessible?
Someone else had a similar problem here and it might be worth trying a completely different directory... maybe even /opt.