Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
2b816075
Commit
2b816075
authored
Feb 25, 2014
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace backticks with Gitlab::Popen
parent
a9dcfd85
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
33 additions
and
24 deletions
+33
-24
app/controllers/admin/background_jobs_controller.rb
app/controllers/admin/background_jobs_controller.rb
+2
-1
config/initializers/2_app.rb
config/initializers/2_app.rb
+1
-1
lib/backup/manager.rb
lib/backup/manager.rb
+6
-1
lib/gitlab/logger.rb
lib/gitlab/logger.rb
+4
-2
lib/gitlab/upgrader.rb
lib/gitlab/upgrader.rb
+3
-2
lib/tasks/gitlab/check.rake
lib/tasks/gitlab/check.rake
+5
-4
lib/tasks/gitlab/info.rake
lib/tasks/gitlab/info.rake
+6
-6
lib/tasks/gitlab/task_helpers.rake
lib/tasks/gitlab/task_helpers.rake
+6
-7
No files found.
app/controllers/admin/background_jobs_controller.rb
View file @
2b816075
class
Admin::BackgroundJobsController
<
Admin
::
ApplicationController
class
Admin::BackgroundJobsController
<
Admin
::
ApplicationController
def
show
def
show
@sidekiq_processes
=
`ps -U
#{
Settings
.
gitlab
.
user
}
-o euser,pid,pcpu,pmem,stat,start,command | grep sidekiq | grep -v grep`
ps_output
,
_
=
Gitlab
::
Popen
.
popen
(
%W(ps -U
#{
Settings
.
gitlab
.
user
}
-o euser,pid,pcpu,pmem,stat,start,command)
)
@sidekiq_processes
=
ps_output
.
split
(
"
\n
"
).
grep
(
/sidekiq/
)
end
end
end
end
config/initializers/2_app.rb
View file @
2b816075
module
Gitlab
module
Gitlab
VERSION
=
File
.
read
(
Rails
.
root
.
join
(
"VERSION"
)).
strip
VERSION
=
File
.
read
(
Rails
.
root
.
join
(
"VERSION"
)).
strip
REVISION
=
`git log --pretty=format:'%h' -n 1`
REVISION
=
Gitlab
::
Popen
.
popen
(
%W(git log --pretty=format:%h -n 1)
).
first
.
chomp
def
self
.
config
def
self
.
config
Settings
Settings
...
...
lib/backup/manager.rb
View file @
2b816075
...
@@ -8,7 +8,7 @@ module Backup
...
@@ -8,7 +8,7 @@ module Backup
s
[
:db_version
]
=
"
#{
ActiveRecord
::
Migrator
.
current_version
}
"
s
[
:db_version
]
=
"
#{
ActiveRecord
::
Migrator
.
current_version
}
"
s
[
:backup_created_at
]
=
Time
.
now
s
[
:backup_created_at
]
=
Time
.
now
s
[
:gitlab_version
]
=
Gitlab
::
VERSION
s
[
:gitlab_version
]
=
Gitlab
::
VERSION
s
[
:tar_version
]
=
%x{tar --version | head -1}
.
gsub
(
/\n/
,
""
)
s
[
:tar_version
]
=
tar_version
Dir
.
chdir
(
Gitlab
.
config
.
backup
.
path
)
Dir
.
chdir
(
Gitlab
.
config
.
backup
.
path
)
...
@@ -98,5 +98,10 @@ module Backup
...
@@ -98,5 +98,10 @@ module Backup
exit
1
exit
1
end
end
end
end
def
tar_version
tar_version
,
_
=
Gitlab
::
Popen
.
popen
(
%W(tar --version)
)
tar_version
.
split
(
"
\n
"
).
first
end
end
end
end
end
lib/gitlab/logger.rb
View file @
2b816075
...
@@ -11,12 +11,14 @@ module Gitlab
...
@@ -11,12 +11,14 @@ module Gitlab
def
self
.
read_latest
def
self
.
read_latest
path
=
Rails
.
root
.
join
(
"log"
,
file_name
)
path
=
Rails
.
root
.
join
(
"log"
,
file_name
)
self
.
build
unless
File
.
exist?
(
path
)
self
.
build
unless
File
.
exist?
(
path
)
logs
=
`tail -n 2000
#{
path
}
`
.
split
(
"
\n
"
)
tail_output
,
_
=
Gitlab
::
Popen
.
popen
(
%W(tail -n 2000
#{
path
}
)
)
tail_output
.
split
(
"
\n
"
)
end
end
def
self
.
read_latest_for
filename
def
self
.
read_latest_for
filename
path
=
Rails
.
root
.
join
(
"log"
,
filename
)
path
=
Rails
.
root
.
join
(
"log"
,
filename
)
logs
=
`tail -n 2000
#{
path
}
`
.
split
(
"
\n
"
)
tail_output
,
_
=
Gitlab
::
Popen
.
popen
(
%W(tail -n 2000
#{
path
}
)
)
tail_output
.
split
(
"
\n
"
)
end
end
def
self
.
build
def
self
.
build
...
...
lib/gitlab/upgrader.rb
View file @
2b816075
...
@@ -42,8 +42,9 @@ module Gitlab
...
@@ -42,8 +42,9 @@ module Gitlab
end
end
def
latest_version_raw
def
latest_version_raw
git_tags
=
`git ls-remote --tags origin | grep tags
\/
v
#{
current_version
.
major
}
`
remote_tags
,
_
=
Gitlab
::
Popen
.
popen
(
%W(git ls-remote --tags origin)
)
git_tags
=
git_tags
.
lines
.
to_a
.
select
{
|
version
|
version
=~
/v\d\.\d\.\d\Z/
}
git_tags
=
remote_tags
.
split
(
"
\n
"
).
grep
(
/tags\/v
#{
current_version
.
major
}
/
)
git_tags
=
git_tags
.
select
{
|
version
|
version
=~
/v\d\.\d\.\d\Z/
}
last_tag
=
git_tags
.
last
.
match
(
/v\d\.\d\.\d/
).
to_s
last_tag
=
git_tags
.
last
.
match
(
/v\d\.\d\.\d/
).
to_s
end
end
...
...
lib/tasks/gitlab/check.rake
View file @
2b816075
...
@@ -168,7 +168,7 @@ namespace :gitlab do
...
@@ -168,7 +168,7 @@ namespace :gitlab do
def
check_migrations_are_up
def
check_migrations_are_up
print
"All migrations up? ... "
print
"All migrations up? ... "
migration_status
=
`bundle exec rake db:migrate:status`
migration_status
,
_
=
Gitlab
::
Popen
.
popen
(
%W(bundle exec rake db:migrate:status)
)
unless
migration_status
=~
/down\s+\d{14}/
unless
migration_status
=~
/down\s+\d{14}/
puts
"yes"
.
green
puts
"yes"
.
green
...
@@ -295,7 +295,7 @@ namespace :gitlab do
...
@@ -295,7 +295,7 @@ namespace :gitlab do
"user.email"
=>
Gitlab
.
config
.
gitlab
.
email_from
"user.email"
=>
Gitlab
.
config
.
gitlab
.
email_from
}
}
correct_options
=
options
.
map
do
|
name
,
value
|
correct_options
=
options
.
map
do
|
name
,
value
|
run
(
"git config --global --get
#{
name
}
"
).
try
(
:squish
)
==
value
run
(
%W(git config --global --get
#{
name
}
)
).
try
(
:squish
)
==
value
end
end
if
correct_options
.
all?
if
correct_options
.
all?
...
@@ -628,7 +628,8 @@ namespace :gitlab do
...
@@ -628,7 +628,8 @@ namespace :gitlab do
end
end
def
sidekiq_process_count
def
sidekiq_process_count
`ps ux`
.
scan
(
/sidekiq \d+\.\d+\.\d+/
).
count
ps_ux
,
_
=
Gitlab
::
Popen
.
popen
(
%W(ps ux)
)
ps_ux
.
scan
(
/sidekiq \d+\.\d+\.\d+/
).
count
end
end
end
end
...
@@ -739,7 +740,7 @@ namespace :gitlab do
...
@@ -739,7 +740,7 @@ namespace :gitlab do
def
check_git_version
def
check_git_version
required_version
=
Gitlab
::
VersionInfo
.
new
(
1
,
7
,
10
)
required_version
=
Gitlab
::
VersionInfo
.
new
(
1
,
7
,
10
)
current_version
=
Gitlab
::
VersionInfo
.
parse
(
run
(
"
#{
Gitlab
.
config
.
git
.
bin_path
}
--version"
))
current_version
=
Gitlab
::
VersionInfo
.
parse
(
run
(
%W(
#{
Gitlab
.
config
.
git
.
bin_path
}
--version)
))
puts
"Your git bin path is
\"
#{
Gitlab
.
config
.
git
.
bin_path
}
\"
"
puts
"Your git bin path is
\"
#{
Gitlab
.
config
.
git
.
bin_path
}
\"
"
print
"Git version >=
#{
required_version
}
? ... "
print
"Git version >=
#{
required_version
}
? ... "
...
...
lib/tasks/gitlab/info.rake
View file @
2b816075
...
@@ -4,20 +4,20 @@ namespace :gitlab do
...
@@ -4,20 +4,20 @@ namespace :gitlab do
task
info: :environment
do
task
info: :environment
do
# check if there is an RVM environment
# check if there is an RVM environment
rvm_version
=
run_and_match
(
"rvm --version"
,
/[\d\.]+/
).
try
(
:to_s
)
rvm_version
=
run_and_match
(
%W(rvm --version)
,
/[\d\.]+/
).
try
(
:to_s
)
# check Ruby version
# check Ruby version
ruby_version
=
run_and_match
(
"ruby --version"
,
/[\d\.p]+/
).
try
(
:to_s
)
ruby_version
=
run_and_match
(
%W(ruby --version)
,
/[\d\.p]+/
).
try
(
:to_s
)
# check Gem version
# check Gem version
gem_version
=
run
(
"gem --version"
)
gem_version
=
run
(
%W(gem --version)
)
# check Bundler version
# check Bundler version
bunder_version
=
run_and_match
(
"bundle --version"
,
/[\d\.]+/
).
try
(
:to_s
)
bunder_version
=
run_and_match
(
%W(bundle --version)
,
/[\d\.]+/
).
try
(
:to_s
)
# check Bundler version
# check Bundler version
rake_version
=
run_and_match
(
"rake --version"
,
/[\d\.]+/
).
try
(
:to_s
)
rake_version
=
run_and_match
(
%W(rake --version)
,
/[\d\.]+/
).
try
(
:to_s
)
puts
""
puts
""
puts
"System information"
.
yellow
puts
"System information"
.
yellow
puts
"System:
\t\t
#{
os_name
||
"unknown"
.
red
}
"
puts
"System:
\t\t
#{
os_name
||
"unknown"
.
red
}
"
puts
"Current User:
\t
#{
`whoami`
}
"
puts
"Current User:
\t
#{
run
(
%W(whoami)
)
}
"
puts
"Using RVM:
\t
#{
rvm_version
.
present?
?
"yes"
.
green
:
"no"
}
"
puts
"Using RVM:
\t
#{
rvm_version
.
present?
?
"yes"
.
green
:
"no"
}
"
puts
"RVM Version:
\t
#{
rvm_version
}
"
if
rvm_version
.
present?
puts
"RVM Version:
\t
#{
rvm_version
}
"
if
rvm_version
.
present?
puts
"Ruby Version:
\t
#{
ruby_version
||
"unknown"
.
red
}
"
puts
"Ruby Version:
\t
#{
ruby_version
||
"unknown"
.
red
}
"
...
...
lib/tasks/gitlab/task_helpers.rake
View file @
2b816075
...
@@ -28,7 +28,7 @@ namespace :gitlab do
...
@@ -28,7 +28,7 @@ namespace :gitlab do
# It will primarily use lsb_relase to determine the OS.
# It will primarily use lsb_relase to determine the OS.
# It has fallbacks to Debian, SuSE, OS X and systems running systemd.
# It has fallbacks to Debian, SuSE, OS X and systems running systemd.
def
os_name
def
os_name
os_name
=
run
(
"lsb_release -irs"
)
os_name
=
run
(
%W(lsb_release -irs)
)
os_name
||=
if
File
.
readable?
(
'/etc/system-release'
)
os_name
||=
if
File
.
readable?
(
'/etc/system-release'
)
File
.
read
(
'/etc/system-release'
)
File
.
read
(
'/etc/system-release'
)
end
end
...
@@ -39,7 +39,7 @@ namespace :gitlab do
...
@@ -39,7 +39,7 @@ namespace :gitlab do
os_name
||=
if
File
.
readable?
(
'/etc/SuSE-release'
)
os_name
||=
if
File
.
readable?
(
'/etc/SuSE-release'
)
File
.
read
(
'/etc/SuSE-release'
)
File
.
read
(
'/etc/SuSE-release'
)
end
end
os_name
||=
if
os_x_version
=
run
(
"sw_vers -productVersion"
)
os_name
||=
if
os_x_version
=
run
(
%W(sw_vers -productVersion)
)
"Mac OS X
#{
os_x_version
}
"
"Mac OS X
#{
os_x_version
}
"
end
end
os_name
||=
if
File
.
readable?
(
'/etc/os-release'
)
os_name
||=
if
File
.
readable?
(
'/etc/os-release'
)
...
@@ -80,13 +80,12 @@ namespace :gitlab do
...
@@ -80,13 +80,12 @@ namespace :gitlab do
#
#
# see also #run_and_match
# see also #run_and_match
def
run
(
command
)
def
run
(
command
)
unless
`
#{
command
}
2>/dev/null`
.
blank?
output
,
_
=
Gitlab
::
Popen
.
popen
(
command
)
`
#{
command
}
`
output
end
end
end
def
uid_for
(
user_name
)
def
uid_for
(
user_name
)
run
(
"id -u
#{
user_name
}
"
).
chomp
.
to_i
run
(
%W(id -u
#{
user_name
}
)
).
chomp
.
to_i
end
end
def
gid_for
(
group_name
)
def
gid_for
(
group_name
)
...
@@ -100,7 +99,7 @@ namespace :gitlab do
...
@@ -100,7 +99,7 @@ namespace :gitlab do
def
warn_user_is_not_gitlab
def
warn_user_is_not_gitlab
unless
@warned_user_not_gitlab
unless
@warned_user_not_gitlab
gitlab_user
=
Gitlab
.
config
.
gitlab
.
user
gitlab_user
=
Gitlab
.
config
.
gitlab
.
user
current_user
=
run
(
"whoami"
).
chomp
current_user
=
run
(
%W(whoami)
).
chomp
unless
current_user
==
gitlab_user
unless
current_user
==
gitlab_user
puts
"
#{
Colored
.
color
(
:black
)
+
Colored
.
color
(
:on_yellow
)
}
Warning
#{
Colored
.
extra
(
:clear
)
}
"
puts
"
#{
Colored
.
color
(
:black
)
+
Colored
.
color
(
:on_yellow
)
}
Warning
#{
Colored
.
extra
(
:clear
)
}
"
puts
" You are running as user
#{
current_user
.
magenta
}
, we hope you know what you are doing."
puts
" You are running as user
#{
current_user
.
magenta
}
, we hope you know what you are doing."
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment