How to execute shell command from Rails?
I am facing a issue when tried to run shell command from rails controller.
Tried in 3 different environments
- Local (Puma)
- Staging Server( standalone passenger)
- Live (Nginx + Passenger 5.3.4)
Ruby installed in live directly by source (no rvm and rbenv)
It is working in Local and Sandbox but 127
error in live
Tried with below 4 ways but all these are woking only in Local and Sandbox not on live
def enable_sidekiq
system 'bundle exec sidekiq -d -e production'
exec('bundle sidekiq -d -e production') #working but stops rail console
%x{bundle exec sidekiq -d -e production}
`bundle exec sidekiq -d -e production`
puts $? # this shows - pid 23543 exit 0 (when successfull)
# this shows - pid 23456 exit 127 (when not successfull)
end
Error:
Passenger AppPreloader: /path/to/project (forking...): No such file or directory - bundle
ruby-on-rails ruby shell nginx passenger
|
show 16 more comments
I am facing a issue when tried to run shell command from rails controller.
Tried in 3 different environments
- Local (Puma)
- Staging Server( standalone passenger)
- Live (Nginx + Passenger 5.3.4)
Ruby installed in live directly by source (no rvm and rbenv)
It is working in Local and Sandbox but 127
error in live
Tried with below 4 ways but all these are woking only in Local and Sandbox not on live
def enable_sidekiq
system 'bundle exec sidekiq -d -e production'
exec('bundle sidekiq -d -e production') #working but stops rail console
%x{bundle exec sidekiq -d -e production}
`bundle exec sidekiq -d -e production`
puts $? # this shows - pid 23543 exit 0 (when successfull)
# this shows - pid 23456 exit 127 (when not successfull)
end
Error:
Passenger AppPreloader: /path/to/project (forking...): No such file or directory - bundle
ruby-on-rails ruby shell nginx passenger
4
You should uservm and rbenv
, becausebundler
depends on rubygems(finds, loads and runs gems). Its a little tricky since rvm and rbenv behave differently in the defferent shells.
– Зелёный
Jan 1 at 13:04
1
I would never recommend starting Sidekiq by starting a new process from your existing Rails app (and definitely would not recommend starting it from a controller action!) I suggest reading the wiki to understand how to start Sidekiq properly.
– anothermh
Jan 1 at 20:43
@Зелёный I would never recommend using RVM or rbenv in a production environment. Docker, for example, does not play very well with them.
– anothermh
Jan 1 at 20:44
@anothermh rvm works in docker very well.
– Зелёный
Jan 1 at 20:49
@parul-kanani Yes, do not start sidekiq from a controller or by forking another process. Also, it doesn't matter if RVM/rbenv play well with docker or not. It is not the best way. If you are using docker, then use supervisor to do so. If you aren't using docker, use your host's/host os's service manager to start it.
– Aaditya Maheshwari
Jan 1 at 23:11
|
show 16 more comments
I am facing a issue when tried to run shell command from rails controller.
Tried in 3 different environments
- Local (Puma)
- Staging Server( standalone passenger)
- Live (Nginx + Passenger 5.3.4)
Ruby installed in live directly by source (no rvm and rbenv)
It is working in Local and Sandbox but 127
error in live
Tried with below 4 ways but all these are woking only in Local and Sandbox not on live
def enable_sidekiq
system 'bundle exec sidekiq -d -e production'
exec('bundle sidekiq -d -e production') #working but stops rail console
%x{bundle exec sidekiq -d -e production}
`bundle exec sidekiq -d -e production`
puts $? # this shows - pid 23543 exit 0 (when successfull)
# this shows - pid 23456 exit 127 (when not successfull)
end
Error:
Passenger AppPreloader: /path/to/project (forking...): No such file or directory - bundle
ruby-on-rails ruby shell nginx passenger
I am facing a issue when tried to run shell command from rails controller.
Tried in 3 different environments
- Local (Puma)
- Staging Server( standalone passenger)
- Live (Nginx + Passenger 5.3.4)
Ruby installed in live directly by source (no rvm and rbenv)
It is working in Local and Sandbox but 127
error in live
Tried with below 4 ways but all these are woking only in Local and Sandbox not on live
def enable_sidekiq
system 'bundle exec sidekiq -d -e production'
exec('bundle sidekiq -d -e production') #working but stops rail console
%x{bundle exec sidekiq -d -e production}
`bundle exec sidekiq -d -e production`
puts $? # this shows - pid 23543 exit 0 (when successfull)
# this shows - pid 23456 exit 127 (when not successfull)
end
Error:
Passenger AppPreloader: /path/to/project (forking...): No such file or directory - bundle
ruby-on-rails ruby shell nginx passenger
ruby-on-rails ruby shell nginx passenger
edited Jan 1 at 12:36
Parul Kanani
asked Jan 1 at 12:27
Parul KananiParul Kanani
618
618
4
You should uservm and rbenv
, becausebundler
depends on rubygems(finds, loads and runs gems). Its a little tricky since rvm and rbenv behave differently in the defferent shells.
– Зелёный
Jan 1 at 13:04
1
I would never recommend starting Sidekiq by starting a new process from your existing Rails app (and definitely would not recommend starting it from a controller action!) I suggest reading the wiki to understand how to start Sidekiq properly.
– anothermh
Jan 1 at 20:43
@Зелёный I would never recommend using RVM or rbenv in a production environment. Docker, for example, does not play very well with them.
– anothermh
Jan 1 at 20:44
@anothermh rvm works in docker very well.
– Зелёный
Jan 1 at 20:49
@parul-kanani Yes, do not start sidekiq from a controller or by forking another process. Also, it doesn't matter if RVM/rbenv play well with docker or not. It is not the best way. If you are using docker, then use supervisor to do so. If you aren't using docker, use your host's/host os's service manager to start it.
– Aaditya Maheshwari
Jan 1 at 23:11
|
show 16 more comments
4
You should uservm and rbenv
, becausebundler
depends on rubygems(finds, loads and runs gems). Its a little tricky since rvm and rbenv behave differently in the defferent shells.
– Зелёный
Jan 1 at 13:04
1
I would never recommend starting Sidekiq by starting a new process from your existing Rails app (and definitely would not recommend starting it from a controller action!) I suggest reading the wiki to understand how to start Sidekiq properly.
– anothermh
Jan 1 at 20:43
@Зелёный I would never recommend using RVM or rbenv in a production environment. Docker, for example, does not play very well with them.
– anothermh
Jan 1 at 20:44
@anothermh rvm works in docker very well.
– Зелёный
Jan 1 at 20:49
@parul-kanani Yes, do not start sidekiq from a controller or by forking another process. Also, it doesn't matter if RVM/rbenv play well with docker or not. It is not the best way. If you are using docker, then use supervisor to do so. If you aren't using docker, use your host's/host os's service manager to start it.
– Aaditya Maheshwari
Jan 1 at 23:11
4
4
You should use
rvm and rbenv
, because bundler
depends on rubygems(finds, loads and runs gems). Its a little tricky since rvm and rbenv behave differently in the defferent shells.– Зелёный
Jan 1 at 13:04
You should use
rvm and rbenv
, because bundler
depends on rubygems(finds, loads and runs gems). Its a little tricky since rvm and rbenv behave differently in the defferent shells.– Зелёный
Jan 1 at 13:04
1
1
I would never recommend starting Sidekiq by starting a new process from your existing Rails app (and definitely would not recommend starting it from a controller action!) I suggest reading the wiki to understand how to start Sidekiq properly.
– anothermh
Jan 1 at 20:43
I would never recommend starting Sidekiq by starting a new process from your existing Rails app (and definitely would not recommend starting it from a controller action!) I suggest reading the wiki to understand how to start Sidekiq properly.
– anothermh
Jan 1 at 20:43
@Зелёный I would never recommend using RVM or rbenv in a production environment. Docker, for example, does not play very well with them.
– anothermh
Jan 1 at 20:44
@Зелёный I would never recommend using RVM or rbenv in a production environment. Docker, for example, does not play very well with them.
– anothermh
Jan 1 at 20:44
@anothermh rvm works in docker very well.
– Зелёный
Jan 1 at 20:49
@anothermh rvm works in docker very well.
– Зелёный
Jan 1 at 20:49
@parul-kanani Yes, do not start sidekiq from a controller or by forking another process. Also, it doesn't matter if RVM/rbenv play well with docker or not. It is not the best way. If you are using docker, then use supervisor to do so. If you aren't using docker, use your host's/host os's service manager to start it.
– Aaditya Maheshwari
Jan 1 at 23:11
@parul-kanani Yes, do not start sidekiq from a controller or by forking another process. Also, it doesn't matter if RVM/rbenv play well with docker or not. It is not the best way. If you are using docker, then use supervisor to do so. If you aren't using docker, use your host's/host os's service manager to start it.
– Aaditya Maheshwari
Jan 1 at 23:11
|
show 16 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53995424%2fhow-to-execute-shell-command-from-rails%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53995424%2fhow-to-execute-shell-command-from-rails%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
4
You should use
rvm and rbenv
, becausebundler
depends on rubygems(finds, loads and runs gems). Its a little tricky since rvm and rbenv behave differently in the defferent shells.– Зелёный
Jan 1 at 13:04
1
I would never recommend starting Sidekiq by starting a new process from your existing Rails app (and definitely would not recommend starting it from a controller action!) I suggest reading the wiki to understand how to start Sidekiq properly.
– anothermh
Jan 1 at 20:43
@Зелёный I would never recommend using RVM or rbenv in a production environment. Docker, for example, does not play very well with them.
– anothermh
Jan 1 at 20:44
@anothermh rvm works in docker very well.
– Зелёный
Jan 1 at 20:49
@parul-kanani Yes, do not start sidekiq from a controller or by forking another process. Also, it doesn't matter if RVM/rbenv play well with docker or not. It is not the best way. If you are using docker, then use supervisor to do so. If you aren't using docker, use your host's/host os's service manager to start it.
– Aaditya Maheshwari
Jan 1 at 23:11