diff --git a/build.sh b/build.sh new file mode 100755 index 000000000..e1beebd09 --- /dev/null +++ b/build.sh @@ -0,0 +1,75 @@ +PWD=`pwd` +NAME=${1:-pilosa} +export GOPATH=$PWD/$NAME +read -p "This will create a new pilosa environment at $GOPATH (DELETING IF NECESSARY!)! Continue? (y/n) " -n 1 -r +if [[ ! $REPLY =~ ^[Yy]$ ]] +then + echo + echo "Aborting!" + exit 1 +fi +echo Building environment \"$NAME\" at $GOPATH... + +rm -rf $GOPATH +mkdir -p $GOPATH/src +git clone git@ops:nuevo-pilosa.git $GOPATH/src/pilosa +cd $GOPATH +ln -s src/pilosa pilosa + +go get github.com/vube/depman +./bin/depman -path=pilosa install + +hg clone -u release https://code.google.com/p/gocircuit src/circuit_src +cp -r src/circuit_src/src/circuit src + +export GOCIRCUIT=$GOPATH/src/circuit_src +export ZKINCLUDE=$GOCIRCUIT/misc/starter-kit-darwin/zookeeper/include +export ZKLIB=$GOCIRCUIT/misc/starter-kit-darwin/zookeeper/lib + +export CGO_CFLAGS="-I$ZKINCLUDE" +export CGO_LDFLAGS="$ZKLIB/libzookeeper_mt.a" + +go install circuit/cmd/... +go install pilosa/... + +cat << EOF > app.config +{ + "Zookeeper": { + "Workers": ["localhost:2181"], + "Dir": "/circuit/pilosa" + }, + "Deploy": { + "Dir": "$GOPATH", + "Worker": "pilosa-worker" + }, + "Build": { + "Host": "localhost", + "Jail": "{{ \`HOME\` | env }}/.pilosa/build", + "ZookeeperInclude": "$ZKINCLUDE", + "ZookeeperLib": "$ZKLIB", + "Tool": "$GOPATH/bin/4build", + "PrefixPath": "", + + "AppRepo": "{rsync}$GOPATH/src/pilosa", + "AppSrc": "$GOPATH/src/pilosa", + + "GoRepo": "{rsync}{{ \`GOROOT\` | env }}", + "RebuildGo": false, + + "CircuitRepo": "{rsync}$GOCIRCUIT", + "CircuitSrc": "/", + + "WorkerPkg": "pilosa/cmd/pilosa-cruncher", + "CmdPkgs": ["pilosa/cmd/pilosa-spawn"], + "ShipDir": "{{ \`HOME\` | env }}/.pilosa/ship" + } +} +EOF + +cat << EOF > activate +export CIR=app.config +export GOPATH=$GOPATH +export PATH=$GOPATH/bin:\$PATH +EOF + +echo Done building environment. Run \". activate\" to set environment variables. diff --git a/commands/pilosa-spawn/spawn.go b/commands/pilosa-spawn/spawn.go new file mode 100644 index 000000000..670ee59ee --- /dev/null +++ b/commands/pilosa-spawn/spawn.go @@ -0,0 +1,21 @@ +package main + +import ( + _ "circuit/load/cmd" + "circuit/use/circuit" + "pilosa/cruncher" + "log" +) + +func main() { + log.Println("Spawning...") + + retrn, addr, err := circuit.Spawn("localhost", []string{"/cruncher"}, cruncher.App{}) + if err != nil { + log.Fatal(err) + } + log.Println(retrn, addr) + + circuit.Hang() +} + diff --git a/commands/pilosa-worker/worker.go b/commands/pilosa-worker/worker.go new file mode 100644 index 000000000..946f5f869 --- /dev/null +++ b/commands/pilosa-worker/worker.go @@ -0,0 +1,8 @@ +package main + +import ( + _ "circuit/load/worker" + _ "pilosa/cruncher" +) + +func main() {} diff --git a/cruncher/cruncher.go b/cruncher/cruncher.go index 309a22a48..8c93f79ed 100644 --- a/cruncher/cruncher.go +++ b/cruncher/cruncher.go @@ -4,6 +4,8 @@ import ( "pilosa/core" "pilosa/db" "log" + "circuit/use/circuit" + "time" ) type Cruncher struct { @@ -53,3 +55,13 @@ func (c *Cruncher) HandleInbox() { } } } + +type App struct{} +func (App) Main() { + log.Println("Starting cruncher!") + time.Sleep(60*time.Second) +} + +func init() { + circuit.RegisterFunc(App{}) +}