Let’s try this food coop software now.
Install Node.js
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
Install MongoDB
vagrant@precise64:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04 LTS
Release: 12.04
Codename: precise
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
sudo apt-get update
sudo apt-get install -y mongodb-org
To start and stop Mongo
sudo service mongod start
sudo service mongod stop
sudo service mongod restart
Install Redis
sudo apt-get upgrade
│ The GRUB boot loader was previously installed to a disk that is no longer present, │
│ or whose unique identifier has changed for some reason. It is important to make │
│ sure that the installed GRUB core image stays in sync with GRUB modules and │
│ grub.cfg. Please check again to make sure that GRUB is written to the appropriate │
│ boot devices. │
│ │
│ If you’re unsure which drive is designated as boot drive by your BIOS, it is often │
│ a good idea to install GRUB to all of them. │
│ │
│ Note: it is possible to install GRUB to partition boot records as well, and some │
│ appropriate partitions are offered here. However, this forces GRUB to use the │
│ blocklist mechanism, which makes it less reliable, and therefore is not │
│ recommended. │
│ │
│ GRUB install devices:
│ [ ] /dev/sda (85899 MB; VBOX_HARDDISK) │
│ [ ] – /dev/sda1 (254 MB; /boot) │
│ [ ] /dev/dm-0 (84833 MB; precise64-root) │
│
│ GRUB failed to install to the following devices: │
│ │
│ /dev/dm-0 │
│ │
│ Do you want to continue anyway? If you do, your computer may not start up properly. │
│ │
│ Writing GRUB to boot device failed – continue?
sudo apt-get install redis-server
Install Grunt
npm install -g grunt-cli
npm ERR! Error: failed to fetch from registry: grunt-cli
curl -sL https://deb.nodesource.com/setup | sudo bash -
The program 'curl' is currently not installed. You can install it by typing:
sudo apt-get install curl
sudo apt-get install curl
sudo apt-get install -y nodejs
npm install -g grunt-cli
npm ERR! Error: EACCES, mkdir ‘/usr/lib/node_modules/grunt-cli’
npm ERR! ERRORS : Please try running this command again as root/Administrator.
sudo !! (AKA sudo npm install -g grunt-cli)
Get into the shared directory
cd ../../vagrant/
npm install
npm WARN deprecated grunt-ngmin@0.0.3: use grunt-ng-annotate instead
npm WARN excluding symbolic link build/defs-config.json -> ../defs-config.json
npm WARN deprecated ngmin@0.4.1: use ng-annotate instead
Another permission error
sudo !!
I guess I could mess with these npm permissions approaches too.
ERRORS Galore! May be npm virtualbox shared folder issue. Let’s try installing in the host computer from the shared folder.
Seems to have worked.
mongod
ERROR
2015-09-21T01:36:47.581+0000 E NETWORK [initandlisten] listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0
$ sudo service mongod stop
$ mongod
2015-09-21T01:38:56.045+0000 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating
$ mongod
2015-09-21T01:41:17.275+0000 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
2015-09-21T01:41:17.275+0000 I CONTROL [initandlisten] dbexit: rc: 100
$ ls -l /var/lib/ | grep mongo
drwxr-xr-x 3 mongodb mongodb 4096 Sep 21 00:57 mongodb
$ sudo chown mongodb /data/db
sudo chown mongodb /data/db
$ mongod
2015-09-21T01:47:08.265+0000 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
Bunch of failed starts and restarts and some confusion between whether service is supposed to be called mongod
or mongodb
.
$ sudo service mongod start
mongod start/running, process 1805
Looking good.
redis-server
[1808] 21 Sep 01:50:43 # Warning: no config file specified, using the default config. In order to specify a config file use 'redis-server /path/to/redis.conf'
[1808] 21 Sep 01:50:43 # Opening port: bind: Address already in use
What’s up with this redis config file? Ah. Just using default. Let’s see what’s up with the address in use issue using the redis-cli
.
$ redis-cli ping
PONG
Ah. Maybe mongodb starts it automatically?
$ mongorestore dump
2015-09-21T01:57:35.087+0000 Failed: error connecting to db server: no reachable servers
$ sudo service mongod restart
$ mongorestore dump
$ mongorestore --host=127.0.0.1 --port=27133 dump
Nope. Where is this config file?
$ ls /etc | grep mongo
mongod.conf
Let’s read someone else’s work on Mongodb on Vagrant box. Anh, that’s not really what I was looking for. Maybe adding this to the vagrant file:
config.vm.network "forwarded_port", guest: 27017, host: 27017
And in /etc/mongod.conf
comment out:
bind_ip = 127.0.0.1
So we can “listen on all interfaces”. Now… $ logout
, $ vagrant reload
$ vagrant ssh
, cd ../../vagrant
$ mongorestore dump
data
data data data
2015-09-21T02:59:10.213+0000 done
Success!
Now back on the host side:
$ bower install
bower ENOENT No bower.json present
┌──────────────────────────────────────────┐
│ Update available: 1.5.2 (current: 1.4.1) │
│ Run npm install -g bower to update. │
Do we have to make our own Bower.json file? Let’s install all that’s in bower_components
dir:
$ bower init
$ bower install angular-mocks -save
$ bower install jcrop -save
$ bower install jquery -save
$ bower install ng-jcrop -save
$ bower install angular -save
Start server (within vagrant box):
$ grunt dev | bunyan
bunyan: command not found
Installs with npm. Let’s try to install in the virtualbox:
$ npm install bunyan
ERRORS
Bunyan is a logging system and even just running the server isn’t working:
$ grunt dev
Loading "Gruntfile.js" tasks...ERROR
>> Error: Cannot find module './server/config'
Warning: Task "dev" not found. Use --force to continue.
Aborted due to warnings.
I think we need to get npm working on our virtualbox. Apparently enabling symlinks in the Virtualbox config:
config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
#
# This is so npm will work in the virtualbox
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant", "1"]
end
On vbox:
$ npm install -g grunt-cli
$ cd ../../vagrant
No no no. Apparently I have to use this version of node.js:
$ sudo apt-add-repository ppa:chris-lea/node.js
Which requires:
sudo apt-get install software-properties-common
and/or
sudo apt-get install python3-software-properties
and/or
sudo apt-get install python-software-properties
Then finally sudo apt-get update
, $ sudo apt-get install -y nodejs
.
Doesn’t look like anything was installed. I should really be using a provisioning script.
Found one: https://github.com/joaquimserafim/vagrant-nodejs-redis-mongodb
And this one: https://github.com/theasta/vagrant-nodejs-dev, which even has it’s own tutorial. Uses ansible which I’m already using and like. Pythaaaaaahn!
And what’s this ubuntu-mongo-redis-consul-node box all about? Pre-provisioned box? Fuck. That’s a three hour download. Maybe not, or at least not yet.
There’s even a service that will generate provisioned Vagrant boxes for you using Chef: http://rove.io/.