Mike Slinn

Connoisseur of Technology

Bash shell on a Heroku Dyno

2013-02-27 / All Blog posts

Up to now most of my work with Heroku has been via the heroku command line client, and pushing builds to app instances to have them compiled and run. Recently I've been messing around with the remote bash shell of my Heroku apps. To enter a remote shell, just type the following from the root directory of a git project that declares your Heroku app as a remote repository. This command uses the heroku client provided by the Heroku toolbelt:

$ heroku run bash

Upon login, you are placed into the root directory of your deployed app. Unfortunately, you do not have access to the table of mounted file systems and you cannot run sudo.

~ $ pwd
/app
~ $ ls -alF
total 64
drwx------ 10 u37570 37570 4096 Dec  1 01:07 ./
drwxr-xr-x 15 root   root  4096 Oct 31  2011 ../
-rwx------  1 u37570 37570  183 Dec  1 01:05 .gitignore*
drwx------  3 u37570 37570 4096 Dec  1 01:05 .ivy2/
drwxrwxr-x  6 u37570 37570 4096 Dec  1 01:05 .jdk/
drwx------  4 u37570 37570 4096 Dec  1 01:08 .sbt_home/
-rw-------  1 u37570 37570   98 Dec  1 01:05 Procfile
-rw-------  1 u37570 37570 3833 Dec  1 01:05 README.md
drwx------  5 u37570 37570 4096 Dec  1 01:05 app/
drwx------  2 u37570 37570 4096 Dec  1 01:05 conf/
drwx------  5 u37570 37570 4096 Dec  1 01:06 project/
drwx------  5 u37570 37570 4096 Dec  1 01:05 public/
-rwx------  1 u37570 37570   27 Dec  1 01:05 system.properties*
drwx------  6 u37570 37570 4096 Dec  1 01:08 target/

Discover total used file space (my slug uses 1.7GB):

~ $ du -sh /
du: cannot read directory `/proc/tty/driver': Permission denied
du: cannot read directory `/proc/1/task/1/fd': Permission denied
du: cannot read directory `/proc/1/task/1/fdinfo': Permission denied
du: cannot read directory `/proc/1/fd': Permission denied
du: cannot read directory `/proc/1/fdinfo': Permission denied
du: cannot access `/proc/11/task/11/fd/4': No such file or directory
du: cannot access `/proc/11/task/11/fdinfo/4': No such file or directory
du: cannot access `/proc/11/fd/4': No such file or directory
du: cannot access `/proc/11/fdinfo/4': No such file or directory
du: cannot read directory `/lost+found': Permission denied
du: cannot read directory `/etc/ssl/private': Permission denied
1.7G /

All your environment variables are available:

~ $ set # Miles of output

ifconfig is not available, but the IP address of your dyno can be discovered this way:

~ $ tail -n 1 /etc/hosts
10.92.81.76 e3d315e6-4392-4f3a-b7ae-75438c469697

You can run sbt, but this is a bad idea, because the Ivy cache is held outside the dyno, and there is no way for you to clean it without using some voodoo.

~ $ sbt update
[info] Loading global plugins from /app/.sbt_home/.sbt/plugins
[info] Loading project definition from /app/project
[info] Set current project to blahblah (in build file:/app/)
[info] Updating {file:/app/}blahblah...
... miles of output ...
[info] Done updating.
[success] Total time: 6 s, completed Feb 28, 2013 4:40:21 AM

Contact Mike Slinn

Unless you are a recruiter, in which case you should not try to make contact!

  • Email
  • Direct: 514-418-0156
  • Mobile: 650-678-2285

Disclaimer

The content on this web site is provided for general information purposes only and does not constitute legal or other professional advice or an opinion of any kind. Users of this web site are advised to seek specific legal advice by contacting their own legal counsel regarding any specific legal issues. Michael Slinn does not warrant or guarantee the quality, accuracy or completeness of any information on this web site. The articles published on this web site are current as of their original date of publication, but should not be relied upon as accurate, timely or fit for any particular purpose.

Accessing or using this web site does not create a client relationship. Although your use of the web site may facilitate access to or communications with Michael Slinn via e-mail or otherwise via the web site, receipt of any such communications or transmissions does not create a client relationship. Michael Slinn does not guarantee the security or confidentiality of any communications made by e-mail or otherwise through this web site.

This web site may contain links to third party web sites. Monitoring the vast information disseminated and accessible through those links is beyond Michael Slinn's resources and he does not attempt to do so. Links are provided for convenience only and Michael Slinn does not endorse the information contained in linked web sites nor guarantee its accuracy, timeliness or fitness for a particular purpose.


comments powered by Disqus

© 1976-2020, Michael Slinn. All rights reserved.