Display NODE_ENV in command line - command-line

I tried to show the NODE_ENV but it fails.
process.env.NODE_ENV
bash: process.env.NODE_ENV: command not found

On MacOS or OSX you can use echo $NODE_ENV

Related

write "message of the day" by images used by vscode remote development

I am using remote development extension in vscode with a Docker image and I would like that when I start it in the console I want to see the message of the day "motd".
The Dockerfile in .devcontaier has this at the end:
COPY motd /etc/
... # change the default user and WORKDIR
CMD cat /etc/motd && /bin/bash
If I run manually this image I see the message but when vscode uses it I don't see it in the console.
The best solution I found so far is
RUN echo "cat /etc/motd" >> $HOME/.bashrc
CMD /bin/bash

AWS ElasticBeanstalk amazon linux pg_config error with psycopg2

I am testing AWS for launching web service.
I stuck with pg_config. Error log is
/app/requirements.txt (line 1))
Using cached psycopg2-2.6.2.tar.gz
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/psycopg2.egg-info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
There are many solutions in stackoverflow, but it doesn't work for me.
packages:
yum:
python-devel: []
postgresql95-devel: []
libjpeg-devel: '6b'
container_commands:
01_migrate:
command: "python manage.py migrate"
02_collectstatic:
command: "python manage.py collectstatic --noinput"
03_createsu:
command: "python manage.py createsu"
leader_only: true
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "onreview.settings"
PYTHONPATH: "$PYTHONPATH"
"aws:elasticbeanstalk:container:python":
WSGIPath: "onreview/wsgi.py"
This is my .ebextensions/python.config files contents. And I'm uploading through zipping my source code.
I changed postgresql95-devel to postgresql-devel, 93, 94, all of it. And I use 9.5 version db right now.
I think --pg-config's path is problem. but I can't change it.
Is there any solution??
p.s I do not want to setup inside the EC2 instance through SSH or something.
You have a syntax error in your original post, packages: should not be indented. I don't know why you have python-devel when python is included in the install, so I can't say that it isn't interfering. Likewise with the line setting the python path.
packages:
yum:
python-devel: []
postgresql95-devel: []
libjpeg-devel: '6b'
container_commands:
01_migrate:
command: "python manage.py migrate"
02_collectstatic:
command: "python manage.py collectstatic --noinput"
03_createsu:
command: "python manage.py createsu"
leader_only: true
option_settings:
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: "onreview.settings"
PYTHONPATH: "$PYTHONPATH"
aws:elasticbeanstalk:container:python:
WSGIPath: "onreview/wsgi.py"

How can the terminal in Jupyter automatically run bash instead of sh

I love the terminal feature and works very well for our use case where I would like students to do some work directly from a terminal so they experience that environment. The shell that launches automatically is sh and does not pick up all of my bash defaults. I can type "bash" and everything works perfectly. How can I make "bash" the default?
Jupyter uses the environment variable $SHELL to decide which shell to launch. If you are running jupyter using init then this will be set to dash on Ubuntu systems. My solution is to export SHELL=/bin/bash in the script that launches jupyter.
I have tried the ultimate way of switching system-wide SHELL environment variable by adding the following line to the file /etc/environment:
SHELL=/bin/bash
This works on Ubuntu environment. Every now and then, the SHELL variable always points to /bin/bash instead of /bin/sh in Terminal after a reboot.
Also, setting up CRON job to launch jupyter notebook at system startup triggered the same issue on jupyter notebook's Terminal.
It turns out that I need to include variable setting and sourcing statements for Bash init file like ~/.bashrc in CRON job statement as follows via the command $ crontab -e :
#reboot source /home/USERNAME/.bashrc && \
export SHELL=/bin/bash && \
/SOMEWHERE/jupyter notebook --port=8888
In this way, I can log in the Ubuntu server via a remote web browser (http://server-ip-address:8888/) with opening jupyter notebook's Terminal default to Bash as same as local environment.
You can add this to your jupyter_notebook_config.py
c.NotebookApp.terminado_settings = {'shell_command': ['/bin/bash']}
With Jupyter running on Ubuntu 15.10, the Jupyter shell will default into /bin/sh which is a symlink to /bin/dash.
rm /bin/sh
ln -s /bin/bash /bin/sh
That fix got Jupyter terminal booting into bash for me.

Kafka with docker

I want to install a kafka image in my docker, I have tried with https://registry.hub.docker.com/u/wurstmeister/kafka/, but when I write in command line docker pull wurstmeister/kafka, I got this error:
/bin/sh: 1: /tmp/download-kafka.sh: Permission denied
Service 'kafka' failed to build: The command [/bin/sh -c /tmp/download-kafka.sh] returned a non-zero code: 126
Anybody knows the problem?
You should add to Dockerfile line:
RUN chmod +x /tmp/download-kafka.sh && sleep 1
Your issue looks the same with this one
I had the same problem and it turned out to be caused by download-kafka.sh having Windows style EOL (CRLF instead of LF) when cloned. If you are running on a Windows machine, make sure that you configure git with core.autocrlf false.
git config --global core.autocrlf false
You can add RUN chmod 777 /tmp/download-kafka.sh
to kafka.Dockerfile just before executing RUN /tmp/download-kafka.sh

Monit to use with virtualenv

I want to monitor django server using monit. However, it won't let me to run "python manage.py runserver" because it is environment specific to the virtualenv that i use.
So i want to do..
workon myvirtualenv
and then run
python manage.py runserver
however I can i achieve that?
Can you string the commands together for your start command?
"workon myvirtualenv && python manage.py runserver"