Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.

It is tricky to write a deploy.sh which can invoke a service and finish normally #196

Open
humorless opened this issue Jun 5, 2019 · 1 comment

Comments

@humorless
Copy link

I used the bash library in lambacd to invoke my deployment script.

(defn deploy [args ctx]
  (shell/bash ctx (:cwd args) "./deploy.sh"))

I put a very simple deploy.sh with certain code snippet like this:

cd ~/backend && nohup java -Dconf=~/backend/config.edn -jar ~/backend/clj-crm.jar &

exit 0

It looked normal to me, but in practice, the deploy never finished. When I took a look from pstree. I saw something like

--- deploy.sh --- java ...

It looked like deploy.sh was blocked by my service. However, I have used nohup command and &.

I changed my code snippet to something like:

tmux new-session -d -s backend 'cd ~/backend && java -Dconf=~/backend/config.edn -jar ~/backend/clj-crm.jar'

exit 0

This time, the deploy could successfully finish, was not blocked by java service anymore. However, I still do not understand why.

@flosell
Copy link
Owner

flosell commented Jun 9, 2019

Hi, I'm not an expert on this but I think this has something to do with how output streams are handled: nohup fails to detect a terminal when running inside LambdaCD so it doesn't redirect the output to nohup.out as it usually does. This seems to block the shell from finishing. Also, for some reason, it only worked for me when I didn't link cd and nohup with &&, no idea why.

But this seems to work:

cd ~/backend
nohup java -Dconf=~/backend/config.edn -jar ~/backend/clj-crm.jar > logfile.txt 2>&1 &

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants