ERROR in Node Sass does not yet support your current environment: Linux

We might come across this error at some point while dealing with node js and its related components.

ERROR in Node Sass does not yet support your current environment: Linux 64-bit with Unsupported runtime (57)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v3.13.1
@ ./lib/scss/bootstrap.scss 4:14-176

Try running the following command and which would fix the above issue.

npm rebuild node-sass

Advertisements

Debian : Setting environment variables for all users

An environment variable like JAVA_HOME can be set in different ways in  linux systems.

#1 . If we set environment variables in .bashrc file found in each users home directory, it will be accessible only for that user.

~/.bashrc   ——> specific to a particular user.

Setting environment variable for all users.
If the environment variable to be available for all users,

#2.   it can be set in /etc/environment

For instance let see how JAVA_HOME can be set,
Open this file in  vim or any editor of your choice, and add following line in it.
JAVA_HOME=”/usr/lib/jvm/java-8-openjdk-amd64″.
This sets JAVA_HOME for default open JDK. Please note that location is specified in quotes,

Then save the file and run the command, to have these these changes in effect immediately.
source /etc/environment
But this is not a recommended method.

#3. Setting via /etc/profile

vim /etc/profile (open the this file in vim )
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
Then save the file and run following command.
source /etc/profile

#4. Setting via /etc/profile.d
This can be viewed as an extension to the above step. Having all application specific environment file in /etc/profile makes the maintenance a hassle. As a solution to this, variables will be specified as a separate module inside the directory /etc/profile.d/. These modules are shell scripts and should end with .sh extension, otherwise system is not going to recognize it. You can read further on this from here.

I think this would be clear, with the following example.
In order to set JAVA_HOME bythis approach, first create a java_dev.sh file inside /etc/profile.d (The file should end with .sh extension ).

Then open this file using vim or any editor
vim /etc/profile.d/java_dev.sh
Then add following lines ( This JAVA_HOME location could be different for others)

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=${JAVA_HOME}/bin:${PATH}

Then save the file and run the following command.
source /etc/profile

You can also consider reading this

Linux – Exclude Certain Files and Folders while Copying

When we copy a certain folder to a remote machine using scp, we might want to exclude some sub folders or files. The following command worked for me in those kind of situations.

scp !(bin) root@target-machine:/opt/your-folder-name/  

In this case, it copies everything except the bin folder from the current working directory to /opt/your-folder-name/ folder in target-machine

Access denied issue with mysqlimport with remote machine

On importing a csv file into a table with same structure that placed on different machine, with mysql import using mysql root user , it is common that we may end up with some access denied error messages.

mysqlimport -h yourhostname –port 3306 -u root -pyourpassword –fields-terminated-by=’;’ –local csv_test tweet.csv

For instance the above stated query which worked in some machines, may raise

mysqlimport: Error: 1045 Access denied for user ‘root’@’ipaddress-of-remote-host’ (using password: YES)

The fix to this issue is as follows :

  1. First check the my.cnf file ( inside /etc/mysql folder ) and look for the line :

bind-address = 127.0.0.1

If it not commented, comments it out, as :

 #bind-address = 127.0.0.1

This tells system that, this mysql is accessible from different hosts as well.

2. Next we need to grant permission to the root user.

For that login to the mysql prompt using mysql -u root -p. Then execute the following query,

GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’ IDENTIFIED BY ‘password’;

3. Now restart mysql using the command:

service mysql restart

VirtualBox – Copy Paste Not working (Debian)

Even though you have set bidirectional for the option Shared Clipboard in settings ( under General –>Advanced ) some times it will not work. The following steps fixed this issue for me.

In the guest OS do the following :

  1. update source.list file
  • enable the contrib repositories; e.g. for Debian 8, make sure your /etc/apt/sources.list contains something like
    deb http://ftp.debian.org/debian jessie main contrib

2.  Install guest addition software.


apt-get update
apt-get install virtualbox-guest-dkms

Error processing package nginx

During the installation of nginx using apt repository ie when we use the following command :
apt-get install nginx we may come across some error messages like this,

Job for nginx.service failed. See ‘systemctl status nginx.service’ and ‘journalctl -xn’ for details.
invoke-rc.d: initscript nginx, action “start” failed.
dpkg: error processing package nginx-full (–configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of nginx:
nginx depends on nginx-full (>= 1.6.2-5+deb8u4) | nginx-light (>= 1.6.2-5+deb8u4) | nginx-extras (>= 1.6.2-5+deb8u4); however:
Package nginx-full is not configured yet.
Package nginx-light is not installed.
Package nginx-extras is not installed.
nginx depends on nginx-full (<< 1.6.2-5+deb8u4.1~) | nginx-light (<< 1.6.2-5+deb8u4.1~) | nginx-extras (<< 1.6.2-5+deb8u4.1~); however:
Package nginx-full is not configured yet.
Package nginx-light is not installed.
Package nginx-extras is not installed.

dpkg: error processing package nginx (–configure):
dependency problems – leaving unconfigured
Errors were encountered while processing:
nginx-full
nginx
E: Sub-process /usr/bin/dpkg returned an error code (1)

Fix

Stopping the apache service (or current webserver) before we try to install nginx, would solve this issue. Once we get nginx installed, we can start apache service again.

Hence the following steps are supposed to solve this issue.

1. sudo systemctl stop apache2.service
2. sudo apt-get install nginx
3. sudo systemctl start apache2.service

Celery in Production – Supervisor

In this tutorial, we are going to see how celery is set up in production environment, where both workers and other processes such as monitoring tool like flower are to be run continuously. During development stage, both worker and flower processes used to get stopped somehow forcing me to restart the every now and then. A solution for this, as suggested in official site of Celery, is to make use of tools like Supervisor.

In production you will want to run the worker in the background as a daemon and some times there may be a chance of stopping of celery worker automatically then it should be restarted automatically. To do these tasks you need to use the tools provided like supervisord.

Installing Supervisor

First we need to set up python virtual environment. Then run the following command to create a virtual environment for our demo projects :
virtualenv env

Now move to this folder env and activate the this virtual environment:
source bin/activate

(Now we need to install both celery and rabitMQ in this virtual environment using pip,)

Now install supervisor using the following command :

pip install supervisor

This would create a configuration file named echo_supervisord_conf

Now run the following command to generate the config file :
echo_supervisord_conf > supervisord.conf

This would generate a config file, supervisord.conf where lies all the keys for our magic………….
Now move this file to the destination folder where we have written codes for celery. In my case I have a folder named project inside this env folder (which contains files such as tasks.py etc )

Now cd to projects folder.

Now open the file we have just copied, and add the following lines

[program:tasks]
command=celery worker -A tasks –loglevel=INFO
stdout_logfile=celeryd.log
stderr_logfile=celeryd.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs=600

[program:flower]
command=celery flower -A tasks
stdout_logfile=flower.log
stderr_logfile=flower.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs=600

Since we need to run both worker and flower processes, they need to be added as two separate tasks as written above. Also we can set these as a group so that they would be started and stopped together. Most of the fields in these are selfexplanatory, however, if you would like to get a clear picture, you can this

Now Starting the demons :
Just go to the project directory (folder where we copied the config file) and open the terminal
and run the following command,
supervisord

This would start both flower and celery worker as demons.

Stopping Supervisord

If we want stop supervisord, just runthe following command,

killall supervisord

Ref :
https://micropyramid.com/blog/celery-with-supervisor/
http://jamie.curle.io/posts/bottle-and-supervisord/
https://serversforhackers.com/monitoring-processes-with-supervisord