Saturday, October 21, 2017

Running Ubuntu on Windows 10 Subsystem for Linux


To install Ubuntu directly to Windows 10, it becomes a desktop app, you need to complete following steps:
  1. From Windows Setting, select "Update and Security"
  2. Select "For Developers" in Update and Security
  3. Then select Developer mode, and pick yes to install the package
  4. Reboot the system
  5. Type "Windows Features" at Task Bar, then select "Windows Subsystem for Linux (Beta)". Windows will update necessary files
  6. Reboot the system
  7. Type "bash" at Task Bar to bring up a terminal, then type y at prompt to install Ubuntu
  8. Create new user and password at prompt
  9. Type bash in Task Bar to start up Ubuntu

Saturday, October 7, 2017

Use Systemd for Running Meteor on Ubuntu 16.04

For myapp, create a service file myapp.service at /etc/systemd/system:

[Unit]
Description=Myapp
After=network.target

[Service]
WorkingDirectory=/home/pwong/myapp
ExecStart=/usr/local/bin/meteor --production
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=Myapp
User=pwong
Group=pwong
Environment=NODE_ENV=production
Environment=PWD=/home/pwong/myapp
Environment=PORT=3000
Environment=HTTP_FORWARDED_COUNT=1
Environment=ROOT_URL=http://myapp.com
Environment=MONGO_URL=mongodb://user:pwd@mongodb0,mongodb1,mongodb2:27017/myapp?replcaSet=rs0
Environment=MONGO_OPLOG_URL=mongodb://user:pwd@mongodb0,mongodb1,mongodb2:27017/local?replcaSet=rs0&authSource=admin

[Install]
WantedBy=multi-user.target

-----------------------------------------------------------------
Note:

1. The above configuration is used for replcation set rs0 and remote mongodb server
2. Without the Install section, the service won't startup during the boot time. This section force the system to create a symbolic link for startup.
3. The local database won't accept user creation, so the user is created at admin. Therefore authSource has to be defined in this case.

Perform the following to enable the service and check the status of the service:

$ sudo systemctl daemon-reload
$ sudo systemctl enable myapp
$ sudo systemctl start myapp
$ sudo systemctl status myapp