Process stops after inline script is done via Vagrant

无人久伴 提交于 2019-12-11 16:58:47

问题


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?


回答1:


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&


来源:https://stackoverflow.com/questions/44553050/process-stops-after-inline-script-is-done-via-vagrant

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!