0

I have a server running in EC2 and every time I need to deploy a new version of my app I run the following script:

#Kills tmux and kills <my-app> process
pkill -f tmux
pkill ./my-app

#Removes old bot files and extracts new ones
rm -rf myapp/*
unzip publish.zip -d myapp

#Grants permissions to the botfile
chmod 750 myapp/*
chown root:ubuntu myapp/*

#Starts bot and creates a new tmux session
pkill -USR1 tmux
tmux new_session -d -s  session-name './myapp/my-app'

The last line to start a new tmux session and runs the app works fine if I invoke it myself from the terminal, however if I run it from within the script results in the following error:

error connecting to /tmp/tmux-1001/default (No such file or directory)

Reading other stack exchange posts it was suggested to add pkill -USR1 tmux to signal tmux although it did not solve the problem. How can I address this?

2 Answers 2

0

The error message you are getting:

error connecting to /tmp/tmux-1000/default (No such file or directory)

implies that there is no tmux session to connect to, so your script appears to not be creating a tmux session. When I run your command

tmux new_session -d -s  session-name './myapp/my-app'

I get the following error:

unknown command: new_session

However running:

tmux new -d -s TestSession -c myapp/my-app

works as expected. This is on: Linux #142-Ubuntu SMP Fri Aug 26 12:12:57 UTC 2022 running: tmux 3.0a

4
  • When using your command in my script, it does not error out but running tmux ls shows no sessions running at all and if I simply try to connect to the named session (i.e. tmux a -t SessionName) I get no server running on /tmp/tmux-1000/default.
    – Heinzen
    Oct 10, 2022 at 20:18
  • Heinzen for some reason tmux is failing to start a detached session - does it work from the command line? if your script is a bash script does adding set -euo pipefail and see if that shows any errors...
    – fcbsd
    Oct 10, 2022 at 21:03
  • Also what is the output of ls -lta /dev/ptmx
    – fcbsd
    Oct 10, 2022 at 21:09
  • 1
    I fixed the issue by not using -d (detaching seemed to cause an issue as you pointed out) and there was a typo in new_session, should be new-session. It works as intended now.
    – Heinzen
    Oct 12, 2022 at 8:48
0

Issue fixed by not detaching the session, removing -d. There is also a typo in new_session, should be new-session.

Replacing the last line with

tmux new-session -s myapp './my-app/MyApp'

Creates a new session myapp which I then access with

tmux a -t myapp

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .