通过 Vagrant 完成内联脚本后进程停止 [英] Process stops after inline script is done via Vagrant
问题描述
在 Vagrant 中,我运行一个内联脚本来启动 Weblogic 和 NodeManager
/opt/weblogic/user_projects/domains/custom/startWeblogic.sh &/opt/weblogic/user_proejcts/domains/custom/bin/startNodeManager &
ps -ef
显示运行内联脚本时两个进程都在运行.但是,如果我在来宾机器中 ssh 并运行 ps -ef
,则找不到两个进程.有没有办法在内联脚本之后保持进程运行?
当前您正在运行该脚本,但它以 root
用户身份执行,因此所有行都仅为该用户添加.您想使用 privileged
选项><块引用>
privileged
(boolean) - 指定是否执行 shell 脚本是否为特权用户 (sudo
).默认情况下这是真".
您将希望使用 vagrant 用户运行脚本,以便您可以更改为
config.vm.provision "shell", 内联: "/vagrant/scripts/install.sh", 特权: false
然后您应该使用 nohup
在会话停止后保持脚本运行
nohup/opt/weblogic/user_projects/domains/custom/startWeblogic.sh &>/home/vagrant/startWeblogic.out&nohup/opt/weblogic/user_proejcts/domains/custom/bin/startNodeManager &>/home/vagrant/startNodeManager.out&
In Vagrant, I run an inline script that starts up Weblogic and NodeManager
/opt/weblogic/user_projects/domains/custom/startWeblogic.sh &
/opt/weblogic/user_proejcts/domains/custom/bin/startNodeManager &
ps -ef
shows that both processes are running when running the inline script. But if I were to ssh in the guest machine and run ps -ef
, neither processes are to be found. Is there a way to keep the processes running after the inline script?
Currently you running the script but its executed as root
user so all the lines are added for this user only. You want to use the privileged
option
privileged
(boolean) - Specifies whether to execute the shell script as a privileged user or not (sudo
). By default this is "true".
you will want to run the script with the vagrant user so you can change to
config.vm.provision "shell", inline: "/vagrant/scripts/install.sh", privileged: false
You should then use nohup
to keep the script running after the session is stopped
nohup /opt/weblogic/user_projects/domains/custom/startWeblogic.sh &> /home/vagrant/startWeblogic.out&
nohup /opt/weblogic/user_proejcts/domains/custom/bin/startNodeManager &> /home/vagrant/startNodeManager.out&
这篇关于通过 Vagrant 完成内联脚本后进程停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!