Windows 10 Linux Subsystem Redis not auto-starting

0

I have installed Redis on Windows 10 Linux Subsystem. I followed the instructions available at https://redis.io/topics/quickstart and I have taken care that I followed all the steps mentioned in section Installing Redis more properly correctly.

However trying to run the following command

sudo update-rc.d redis_6379 defaults

I am getting following error:

~$ sudo update-rc.d redis_6379 defaults
insserv: warning: script 'K01redis_6379' missing LSB tags and overrides
insserv: warning: script 'redis_6379' missing LSB tags and overrides
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'cron' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `cron'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `cron'
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
The script you are attempting to invoke has been converted to an Upstart
job, but lsb-header is not supported for Upstart jobs.
insserv: warning: script 'friendly-recovery' missing LSB tags and overrides
insserv: Default-Start undefined, assuming empty start runlevel(s) for script `friendly-recovery'
insserv: Default-Stop  undefined, assuming empty stop  runlevel(s) for script `friendly-recovery'

Manually starting the server works:

~$ sudo /etc/init.d/redis_6379 start
Starting Redis server...
~$ redis-cli ping
PONG

Can anybody please help me in configuring Redis on WLS so that it automatically starts in background like it is the case on actual Ubuntu machine?

Thanks.

Jignesh Gohel

Posted 2017-08-09T07:34:58.903

Reputation: 453

Answers

2

Here are my instructions on how I have configured redis to start as background task on Windows startup.

  1. Install WSL (this is tested with Ubuntu 18.04 version)

  2. Install redis-server inside WSL:

    sudo apt install redis-server
    
  3. Add sudo permission to your user to execute service command without password Open sudoers file sudo visudo and add to end:

    your_username ALL=NOPASSWD:/usr/sbin/service redis-server
    

    or if you want to disable sudo passwords generally add this to the end:

    your_username ALL=(ALL:ALL) NOPASSWD:ALL
    
  4. Create vbs file e.g. start-redis.vbs inside startup folder (Open Run and enter shell:startup)

    In vbs file insert following:

    Set oShell = CreateObject("WScript.Shell")
    oShell.Run "wsl", 0
    oShell.Run "bash -c ""sudo service redis-server start --daemonize yes"""
    

That's it. You can try it by running vbs script and then run htop inside WSL terminal. You should see that redis is running.

I have posted these instructions on GitHub.

Tomislav Brabec

Posted 2017-08-09T07:34:58.903

Reputation: 121

0

  1. you can wait for the next release of Windows or install the insider-build that supports background services https://blogs.msdn.microsoft.com/commandline/2017/12/04/background-task-support-in-wsl/
  2. you can install the windows redis service (no Linux subsystem needed) https://github.com/MicrosoftArchive/redis Personal experience was, this works fine for a single test instance, but has major headaches trying to create a reliable cluster.
  3. run a Linux instance either as VM or on a separate server.

If this is a developer instance to test code go with 2 or 3. If it is a production deployment and you are expecting to run a cluster then 3. WSL is create for running small scripts, testing things but I have not found it very friendly as a replacement for Linux server. YMMV

rob

Posted 2017-08-09T07:34:58.903

Reputation: 575