Thursday, April 25, 2024
HomeGolangOperating Go Applications In IronWorker

Operating Go Applications In IronWorker


Introduction
Iron.io has a product referred to as IronWorker which gives a process oriented Linux container which you can run your packages inside. In case you are unsure what I imply, consider this as having a brief Linux digital machine immediately obtainable on your private however quick time period use. IronWorker permits you to load your binaries, code information, assist information, shells scripts and absolutely anything else chances are you’ll must run your program within the container. You specify a single process to execute, similar to working a shell script or a binary and IronWorker will carry out that process when requested. As soon as the duty is full, IronWorker will tear down the container as if it by no means existed.

In case you are creating in Home windows or on the Mac and plan to load and run pre-built binaries in IronWorker, they have to be constructed for Linux. If that might be an issue don’t despair, you’ve got choices.

You possibly can create an Ubuntu VM so you’ll be able to construct the Linux binaries you want. That is what I do. I don’t develop in my Ubuntu VM, I take advantage of it as a testing and staging space. Your second possibility is to construct your program inside the IronWorker container after which execute it. You’ve gotten lots of flexibility to do what you want with IronWorker.

To Set up or To not Set up Ubuntu
I extremely advocate that you just purchase VMWare Fusion or Parallels and create an Ubuntu VM. A lot of the cloud primarily based environments chances are you’ll select to make use of on your testing and manufacturing environments might be working Linux. It helps to stage and take a look at issues earlier than importing code to those environments. I take advantage of VMWare Fusion and I like the product. VMWare Fusion will value round $60 USD and Ubuntu is FREE. I run Ubuntu 12.04 LTS however model 13.04 is now obtainable.

http://www.vmware.com/merchandise/fusion/
http://www.ubuntu.com/obtain/desktop

On this submit I might be utilizing my Mac for every part. So if you’re working Home windows it is best to be capable of comply with alongside. When you see easy methods to construct your functions contained in the IronWorker container, you’ll know easy methods to load and run Linux binaries. For many who are taken with establishing or utilizing Ubuntu, learn the following part. If you wish to proceed in your Home windows or Mac atmosphere, go to the Putting in Ruby part.

Setting Up Your Terminal In Ubuntu
In case you determined to go forward and set up an Ubuntu VM or you have already got one, superior. Right here are some things you’ll want to achieve this you need to use IronWorker.
The primary Icon within the Launcher bar is the Sprint Dwelling Icon. Choose this and carry out a seek for the Terminal utility.

You will notice a number of terminal functions present up. Choose the Terminal program, which is able to launch a Terminal Session. Now again in Launcher you will notice an icon for the Terminal session you began. Proper Click on on the Terminal Icon and choose Lock To Launcher.

One final step, we have to change a configuration possibility for Terminal:


Screen Shot

Make certain the Terminal session is the lively program and transfer your mouse to the highest of the display. The menu for Terminal will seem. Below Edit select Profile Preferences. Then choose the Title and Command tab and examine the Run command as a login shell. We want this for our Ruby packages to work correctly in our Terminal classes.

Putting in Ruby
Earlier than we will begin utilizing IronWorker we want the newest model of Ruby put in. IronWorker gives a Ruby primarily based command line instrument that permits us to add IronWorker duties for the totally different tasks we create.

Window Customers

In Home windows use this web site to put in the newest model of Ruby:

http://rubyinstaller.org/

As soon as you might be achieved skip to the following part referred to as Putting in IronWorker.

Mac and Linux Customers

On the Mac and Linux I’ve discovered the easiest way to put in and handle Ruby is with the Ruby Model Supervisor (RVM):

https://rvm.io/rvm/set up

Carry out these steps on each your Mac and Linux working methods. Open a Terminal session and run this command:

Use the backslash when working the command. This prevents misbehaving when you’ve got aliased it with configuration in your ~/.curlrc file.

That command ought to obtain the newest model of Ruby and make it the default model. Earlier than shifting on, shut your Terminal session and begin a brand new one. Examine that every part is nice by working this command:

run rvm record

This ought to be the output:

rvm rubies

=* ruby-2.0.0-p247 [ x86_64 ]

There could also be a more recent model of Ruby by the point you might be studying this. However so long as the model is bigger than or equal to 2.0.0 and has the =* operator in entrance, you’ll be all set.

In case you are unsure when you’ve got the right default model set and need to make completely certain, run this command:

rvm use ruby-2.0.0-p247 –default

Simply be sure you specify the model appropriately.

Simply on your info, the rvm instrument and the totally different variations of Ruby you put in get positioned in a folder referred to as .rvm inside your $HOME folder. It will likely be a hidden folder. To see that’s does exist, run the next command in your Terminal session:

cd $HOME
ls -d .rvm

This could show the identify of the listing again within the Terminal session.Putting in IronWorker
With Ruby correctly put in we will set up the IronWorker instrument. This instrument is a Ruby program that permits us to create duties by importing our packages and assist information into IronWorker.

To put in the instrument we should set up the IronWorker Ruby gem. Gem’s are Ruby packages that get put in underneath the default model of Ruby. That is why I burdened we have now the appropriate default model set.

Run the next command within the Terminal session:

gem set up iron_worker_ng

If every part installs correctly, the output ought to finish like this:

7 gems put in

As a ultimate take a look at to ensure every part is setup appropriately, run the IronWorker program:

iron_worker

If every part is working correctly it is best to get the next output:

utilization: iron_worker COMMAND [OPTIONS]

    COMMAND: add, patch, queue, retry, schedule, log, run, set up, webhook, information
    run iron_worker COMMAND –assist to get extra details about every command

Now we have now our surroundings setup to speak with the IronWorker platform. Be sure to do that in all your environments.

The Check Program
I’ve constructed a take a look at utility that we’re going to run in IronWorker. To obtain the code and the IronWorker assist information, run the next instructions:

cd $HOME
export GOPATH=$HOME/instance
go get github.com/goinggo/ironworker

This may copy, construct and set up the code into the instance folder underneath $HOME. This system has been written to check a number of issues in regards to the IronWorker Linux container atmosphere. Let’s assessment the code for this system first and take a look at it regionally.

For IronWorker to be actually efficient you need to construct packages that carry out a selected process. This system ought to be designed to be began on demand or on a schedule, run after which be terminated. You don’t need to construct packages that run for lengthy intervals of time. The take a look at program runs for 60 seconds earlier than it terminates.

There have been two issues I needed to find out about IronWorker that this system assessments. First, I needed to know the way logging labored. Second, I needed to know if this system would obtain OS alerts once I requested the working program to be killed.

With all that stated let’s assessment the code we’re going to run.

Right here is the logging code which might be discovered within the helper bundle:

bundle helper

import (
    “fmt”
    “runtime”
    “time”
)

func WriteStdout(goRoutine string, functionName string, message string) {
    fmt.Printf(“%s : %s : %s : %sn”,
        time.Now().Format(“2006-01-02T15:04:05.000”),
        goRoutine,
        functionName,
        message)
}

func WriteStdoutf(goRoutine string, functionName string, format string, a …interface{}) {
    WriteStdout(goRoutine, functionName, fmt.Sprintf(format, a…))
}

There may be nothing fancy right here, simply an abstraction layer so I alter out the logging mechanism if this doesn’t work.

Right here is the controller code that manages the beginning and termination of this system:

bundle controller

import (
    “os”
    “os/sign”

    “github.com/goinggo/ironworker/helper”
    “github.com/goinggo/ironworker/program”
)

func Run() {
    helper.WriteStdout(“Predominant”, “controller.Run”, “Began”)

    // Create a channel to speak with the OS.
    sigChan := make(chan os.Sign, 1)

    // Create a channel to let this system inform us it’s achieved.
    waitChan := make(chan bool)

    // Create a channel to close down this system early.
    shutChan := make(chan bool)

    // Launch the work routine.
    go program.DoWork(shutChan, waitChan, “Check”)

    // Ask the OS to inform us about interrupt occasions.
    sign.Notify(sigChan, os.Interrupt)

    for {
        choose {
        case <-sigchan:
            helper.WriteStdout(“Predominant”, “controller.Run”, “******> Program Being Killed”)

            // Sign this system to shutdown and watch for affirmation.
            shutChan <- true
            <-shutChan

            helper.WriteStdout(“Predominant”, “controller.Run”, “******> Shutting Down”)
            return

        case <-waitchan:
            helper.WriteStdout(“Predominant”, “controller.Run”, “******> Shutting Down”)
            return
        }
    }
}

I prefer to shutdown my functions gracefully, so if I might obtain an OS sign on a kill request, that might be implausible. I’m not a channel guru and I’m certain there are higher methods to perform this. I welcome any recommendations. For now that is what we obtained.

The operate creates three channels. The primary channel is used to obtain alerts from the OS. The second channel is utilized by the Go routine that’s performing this system logic to sign when it’s achieved. The third channel is utilized by the controller to sign the Go routine to terminate early if needed.

This system.DoWork operate is began as a Go routine after which the controller waits for both the OS to sign or the working Go routine to sign it’s achieved. If the OS alerts to terminate, then the controller makes use of the shutdown channel and waits for the Go routine to reply. Then every part shuts down gracefully.

Right here is the code for the Go routine that’s simulating the work:

bundle program

import (
    “time”

    “github.com/goinggo/ironworker/helper”
)

func DoWork(shutChan chan bool, waitChan chan bool, logKey string) {
    helper.WriteStdout(“Program”, “program.DoWork”, “Program Began”)

    defer func() {
        waitChan <- true
    }()

    // Carry out work for 60 seconds
    for rely := 0; rely < 240; rely++ {
        choose {
        case <-shutChan:
            helper.WriteStdout(“Program”, “program.DoWork”, “Data : Accomplished : KILL REQUESTED”)
            shutChan <- true
            return

        default:
            helper.WriteStdoutf(“Program”, “program.DoWork”, “Data : Performing Work : %d”, rely)
            time.Sleep(time.Millisecond * 250)
        }
    }

    helper.WriteStdout(“Program”, “program.DoWork”, “Accomplished”)
}

The DoWork operate prints a message to the log each 250 milliseconds 240 occasions. This offers us a minute of labor that have to be carried out. After every write log name, the operate checks if the shutdown channel has been signaled. If it has, the operate terminates instantly.

Simply to have an entire code pattern within the submit, right here is the principle operate:

bundle principal

import (
    “github.com/goinggo/ironworker/controller”
    “github.com/goinggo/ironworker/helper”
)

func principal() {
    helper.WriteStdout(“Predominant”, “principal”, “Began”)

    controller.Run()

    helper.WriteStdout(“Predominant”, “principal”, “Accomplished”)
}

In your native atmosphere, mine being the Mac, obtain the code and let Go instrument construct and set up the applying.

cd $HOME
export GOPATH=$HOME/instance
go get github.com/goinggo/ironworker
cd $HOME/instance/bin
./ironworker

Whenever you run this system, let it run to completion. You need to see the next output:

2013-09-07T11:42:48.701 : Predominant : principal : Began
2013-09-07T11:42:48.701 : Predominant : controller.Run : Began
2013-09-07T11:42:48.701 : Program : program.DoWork : Program Began
2013-09-07T11:42:48.701 : Program : program.DoWork : Data : Performing Work : 0
2013-09-07T11:42:48.951 : Program : program.DoWork : Data : Performing Work : 1
2013-09-07T11:42:49.203 : Program : program.DoWork : Data : Performing Work : 2
2013-09-07T11:42:49.453 : Program : program.DoWork : Data : Performing Work : 3
2013-09-07T11:42:49.704 : Program : program.DoWork : Data : Performing Work : 4
2013-09-07T11:42:49.955 : Program : program.DoWork : Data : Performing Work : 5

2013-09-07T11:43:48.161 : Program : program.DoWork : Data : Performing Work : 237
2013-09-07T11:43:48.412 : Program : program.DoWork : Data : Performing Work : 238
2013-09-07T11:43:48.662 : Program : program.DoWork : Data : Performing Work : 239
2013-09-07T11:43:48.913 : Program : program.DoWork : Accomplished
2013-09-07T11:43:48.913 : Predominant : controller.Run : ******> Shutting Down
2013-09-07T11:43:48.913 : Predominant : principal : Accomplished

This system began and terminated efficiently. So the Controller logic is working. This time let’s kill this system early by hitting <Ctrl> C after it begins:

2013-09-07T11:46:31.854 : Predominant : principal : Began
2013-09-07T11:46:31.854 : Predominant : controller.Run : Began
2013-09-07T11:46:31.854 : Program : program.DoWork : Program Began
2013-09-07T11:46:31.854 : Program : program.DoWork : Data : Performing Work : 0
2013-09-07T11:46:32.105 : Program : program.DoWork : Data : Performing Work : 1
2013-09-07T11:46:32.356 : Program : program.DoWork : Data : Performing Work : 2
2013-09-07T11:46:32.607 : Program : program.DoWork : Data : Performing Work : 3
^C2013-09-07T11:46:32.706 : Predominant : controller.Run : ******> OS Notification: interrupt : 0x2
2013-09-07T11:46:32.706 : Predominant : controller.Run : ******> Program Being Killed
2013-09-07T11:46:32.857 : Program : program.DoWork : Data : Accomplished : KILL REQUESTED
2013-09-07T11:46:32.857 : Predominant : controller.Run : ******> Shutting Down
2013-09-07T11:46:32.857 : Predominant : principal : Accomplished

As quickly as I hit <Ctrl> C the OS signaled this system with the syscall.SIGINT message. That brought about the Controller to sign the working program to shutdown and this system terminated gracefully.

Configuring IronWork
That is the documentation for utilizing IronWorker:

http://dev.iron.io/employee/

I’m going to stroll you thru the method for the take a look at utility we have now. Login to your Iron.io account and choose Tasks from the highest menu:

Screen Shot

Enter Check into the textual content field and hit the Create New Challenge button. That ought to ship you to the next display:

Screen Shot

Choose the Key icon which is the place you’ll find the Credentials for this venture. We want these credentials to create a particular file referred to as iron.json. This file might be required by the IronWorker Ruby program to load our duties into this venture.

In our Terminal session let’s transfer to the folder the place the IronWorker script information are positioned. I need to work with the buildandrun scripts:

cd $HOME/instance/src/github.com/goinggo/ironworker/scripts/buildandrun
ls -l

You need to see the next information:

-rw-r–r– 1 invoice workers 995 Sep 8 20:12 buildandrun.sh
-rw-r–r– 1 invoice workers 106 Sep 8 20:12 buildandrun.employee
-rw-r–r– 1 invoice workers 81 Sep 8 20:12 iron.json

You’ll discover a iron.json file within the folder. Edit the file and put in your credentials:

{
    “project_id” : “XXXXXXXXXXXXXXXXXXXXXX”,
    “token” : “XXXXXXXXXXXXXXXXXXXXXX”
}

The following file we need to have a look at is the .employee file. Right here is the documentation for .employee information:

http://dev.iron.io/employee/reference/dotworker/

Here’s what the buildandrun.employee file seems like:

runtime ‘binary’

exec ‘buildandrun.sh’

The buildandrun.employee file is telling the IronWorker Ruby program to add and execute the buildandrun.sh file. That is the one file that might be positioned into the IronWork container.  Here’s what the buildandrun.sh file seems like:

export HOME_FOLDER=”$HOME/Container”
export CODE_FOLDER=”$HOME_FOLDER/code”
export PROGRAM_FOLDER=”$CODE_FOLDER/src/github.com/goingo/ironworker”

if [ ! -e $CODE_FOLDER/bin/ironworker ]
then
  mkdir $HOME_FOLDER
  cd $HOME_FOLDER
  curl https://go.googlecode.com/information/go1.1.2.linux-amd64.tar.gz -o p.tar.bz2 && tar xf p.tar.bz2 && rm p.tar.bz2
  export GOARCH=”amd64″
  export GOBIN=””
  export GOCHAR=”6″
  export GOEXE=””
  export GOHOSTARCH=”amd64″
  export GOHOSTOS=”linux”
  export GOOS=”linux”
  export GOPATH=”$CODE_FOLDER”
  export GORACE=””
  export GOROOT=”$HOME_FOLDER/go”
  export GOTOOLDIR=”$HOME_FOLDER/go/pkg/instrument/linux_amd64″
  export CC=”gcc”
  export GOGCCFLAGS=”-g -O2 -fPIC -m64 -pthread”
  export CGO_ENABLED=”1″
  export PATH=$GOROOT/bin:$PATH
  go get github.com/goinggo/ironworker

  #git clone https://username:password@github.com/goinggo/ironworker $PROGRAM_FOLDER
  #cd $PROGRAM_FOLDER
  #go clear -i
  #go construct
  #go set up
fi

cd $CODE_FOLDER/bin
./ironworker

This script assessments to see if the ironworker take a look at utility already exists. If it doesn’t, it then proceeds to obtain the newest Linux binary bundle for Go and builds this system utilizing the Go instrument. As soon as the construct and set up is full, the script executes this system.

You’ll discover these strains have been commented out within the shell script:

  #git clone https://username:password@github.com/goinggo/ironworker $PROGRAM_FOLDER
  #cd $PROGRAM_FOLDER
  #go clear -i
  #go construct
  #go set up

In case you have a repository that requires authentication you need to use this method. This calls git clone the identical approach the Go instrument does, so every part is copied to the appropriate listing construction. In case your code references different libraries, you will have to do this manually.  In case you run the Go Get command with the [-x] possibility, you’ll be able to see all of the calls the Go instrument points. Simply copy what you want and add it to your shell script.

IronWorker does have a duplicate of the Linux binary bundle for Go model 1.0.2 already pre-configured in each IronWorker container. The script installs the newest model to point out you the way that may be completed if the model you want isn’t the one put in. The method can be used to put in different packages that is perhaps required.

If you wish to construct the code each time the duty runs, you might be smarter and run go model first. If the appropriate model isn’t already obtainable then you’ll be able to obtain the model of Go you want:

export HOME_FOLDER=”$HOME/Container”
export CODE_FOLDER=”$HOME_FOLDER/code”
export PROGRAM_FOLDER=”$CODE_FOLDER/src/github.com/goingo/ironworker”

go model > ver.txt
goversion=$(<ver.txt)
head ver.txt

if [ “$goversion” != “go version go1.1.2 linux/amd64” ]
then
  mkdir $HOME_FOLDER
  cd $HOME_FOLDER
  curl https://go.googlecode.com/information/go1.1.2.linux-amd64.tar.gz -o p.tar.bz2 && tar xf p.tar.bz2 && rm p.tar.bz2
  export GOARCH=”amd64″
  export GOBIN=””
  export GOCHAR=”6″
  export GOEXE=””
  export GOHOSTARCH=”amd64″
  export GOHOSTOS=”linux”
  export GOOS=”linux”
  export GOPATH=”$CODE_FOLDER”
  export GORACE=””
  export GOROOT=”$HOME_FOLDER/go”
  export GOTOOLDIR=”$HOME_FOLDER/go/pkg/instrument/linux_amd64″
  export CC=”gcc”
  export GOGCCFLAGS=”-g -O2 -fPIC -m64 -pthread”
  export CGO_ENABLED=”1″
  export PATH=$GOROOT/bin:$PATH
fi

go get -x github.com/goinggo/ironworker
cd $CODE_FOLDER/bin
./ironworker

Loading IronWork With A Job
We’ve got every part we have to load and run our first process for the Check venture. In your Terminal session run the next command:

cd $HOME/instance/src/github.com/goinggo/ironworker/scripts/buildandrun
iron_worker add buildandrun

If every part is profitable it is best to see the next output:

——> Creating shopper
        Challenge ‘Check’ with id=‘522b4c518a0c960009000007’
——> Creating code bundle
        Discovered workerfile with path=‘buildandrun.employee’
        Detected exec with path=‘buildandrun.sh’ and args=‘{}’
        Code bundle identify is ‘buildandrun’
——> Importing code bundle ‘buildandrun’
        Code bundle uploaded with id=‘522d147b91c530531f6f4e92’ and revision=‘1’
        Examine ‘https://hud.iron.io/tq/tasks/522b4c518a0c960009000007/code/522d147b91c530531f6f4e92 ‘ for more information

Return to the Iron.io web site and let’s see if our new process is there. Choose Tasks once more from the principle menu and choose the Employee button to the appropriate of your Check venture.

Screen Shot

Choose the Duties tab and it is best to see the buildandrun process we simply uploaded. Choose the duty and it is best to see the next display:

Screen Shot

Screen Shot

There’s a large gray button that claims Queue a Job. Let’s hit that button to run our process.

This dialog field will popup. Use all of the defaults and hit the Queue Job button.

This may queue the duty after which it ought to begin working.

When you hit the queue button the display ought to change:

Screen Shot

Screen Shot

The duty will begin within the queued state, then working and at last full. As soon as the duty is finished, click on on the Log hyperlink.

Screen Shot

Screen Shot

You will notice the shell script did every part completely. It downloaded Go and efficiently constructed this system. Then it began executing it.

Let’s run this system once more and examine two issues. First, let’s see if the container is saved and the obtain of Go doesn’t must happen once more. Second, let’s kill this system early and see if it receives any OS alerts.

Hit the Queue a Job button once more and after a number of seconds let’s kill it:

Screen Shot

Screen Shot

Screen Shot

You possibly can see that I killed the duty 21 seconds into the run. After I have a look at the logs I’m a bit disenchanted. First, the duty downloaded Go once more. This implies I’ve a brand new and clear IronWorker container each time the duty runs. Second, this system didn’t obtain any OS alerts once I issued the kill. It seems the IronWork container is pressured to die and this system will get no OS notifications.

It’s not the tip of the world, simply one thing that’s good to know. Primarily based on this new info it appears we need to load binaries into the IronWorker container after we can. This fashion we don’t must spend time downloading issues that may be pre-compiled. Nonetheless, I used to be ready to make use of IronWorker from my Mac atmosphere which is an actual plus.

However, having Go construct and set up your program each time might be big. In case you add code modifications to your repository you don’t must add a brand new revision of the duty. The Go instrument will pull down the newest code, construct it and run this system. Then once more, that would trigger issues.

On the finish of the day that you must determine what’s greatest on your totally different eventualities. What’s superior is that IronWorker provides you all the flexibleness that you must make it work.

Working With Builder Duties
Builder Duties are a hidden gem inside IronWorker. A builder process permits you to construct your code and generate a process that you’ll use on your utility inside IronWorker. That is actually the most effective of each worlds since you don’t must obtain Go and construct the code each time the duty runs. You are able to do your construct as soon as. Your utility process runs instantly as a result of it’s at all times able to go together with the binaries and different assist information it wants.

Return into the scripts folder and discover the sub-folder referred to as buildertask. Let’s rapidly run by way of the information and see how this works.

The task-builder.sh file is the script that is aware of easy methods to construct our code.

export HOME_FOLDER=”$HOME/Container”
export CODE_FOLDER=”$HOME_FOLDER/code”
export PROGRAM_FOLDER=”$CODE_FOLDER/src/github.com/goingo/ironworker”

mkdir $HOME_FOLDER
cd $HOME_FOLDER
curl https://go.googlecode.com/information/go1.1.2.linux-amd64.tar.gz -o p.tar.bz2 && tar xf p.tar.bz2 && rm p.tar.bz2
export GOARCH=”amd64″
export GOBIN=””
export GOCHAR=”6″
export GOEXE=””
export GOHOSTARCH=”amd64″
export GOHOSTOS=”linux”
export GOOS=”linux”
export GOPATH=”$CODE_FOLDER”
export GORACE=””
export GOROOT=”$HOME_FOLDER/go”
export GOTOOLDIR=”$HOME_FOLDER/go/pkg/instrument/linux_amd64″
export CC=”gcc”
export GOGCCFLAGS=”-g -O2 -fPIC -m64 -pthread”
export CGO_ENABLED=”1″
export PATH=$GOROOT/bin:$PATH

go get github.com/goinggo/ironworker

cd $CODE_FOLDER/bin
cp ironworker $HOME/construct/ironworker

The code downloads Go after which makes use of the Go instrument to construct this system. On the finish of the script we copy the binary that the Go instrument constructed to the IronWorker staging space. Something you copy to this folder might be positioned into our new utility process.

The process.sh file is the script that’s executed by the applying process.

./ironworker

In our case we solely must run the binary. Keep in mind the binary is being created by the task-builder.sh script file.

The process.employee file performs all of the magic:

runtime ‘binary’
exec ‘process.sh’
construct ‘sh ./task-builder.sh’
file ‘task-builder.sh’

The employee file tells IronWorker that our utility process is a binary and to load and run the duty.sh script. Subsequent we have now the construct command. This tells IronWorker to carry out a distant construct by exexuting the task-builder.sh script. The file command pulls the task-builder.sh file into the builder process so it may possibly executed remotely.

Let’s navigate to the buildertask folder and check out all this out:

cd $HOME/instance/src/github.com/goinggo/ironworker/scripts/buildertask

We have to edit the iron.json file with the credentials once more. When you try this run the next command:

iron_worker add process

This time the IronWorker will take a bit longer to run. It will likely be performing a distant construct and we should wait till it’s full. As soon as every part is finished it is best to see the next:

——> Creating shopper
        Challenge ‘Check’ with id=‘522b4c518a0c960009000007’
——> Creating code bundle
        Discovered workerfile with path=‘process.employee’
        Detected exec with path=‘process.sh’ and args=‘{}’
        Merging file with path=‘task-builder.sh’ and dest=”
        Code bundle identify is ‘process’
——> Importing and constructing code bundle ‘process’
        Distant constructing employee
        Code bundle uploaded with id=‘522d0cad3cb46653c5e15cbe’ and revision=‘1’
        Examine ‘https://hud.iron.io/tq/tasks/522b4c518a0c960009000007/code/522d0cad3cb46653c5e15cbe ‘ for more information

Now let’s change to the Iron.io web site and see what we have now. Return to the Duties tab and it is best to see two new duties:

Screen Shot

You’ll discover the duty::builder process has already been executed. That is the distant construct that was being carried out. Let’s have a look at the logs. You will notice that the Go binary bundle for Linux was downloaded and the venture was additionally downloaded and constructed. Have a look at the final two strains within the log:

Screen Shot

That is the place we copied the binary to the staging folder construct. We didn’t have any errors or issues coping the ultimate binary.

Now we will strive working the applying process. Choose process from the Job record and queue the job. It ought to begin proper up and run for a minute. As soon as it’s achieved let’s have a look at the log:

Screen Shot

Screen Shot

Whenever you have a look at the log you’ll be able to see this system begins working. There is no such thing as a downloading of Go or every other construct work.

Utilizing a builder process is an effective way to have IronWorker stage and construct the code for us. In case you change the code and must carry out one other construct it’s essential to run the IronWorker program once more. This may create new revisions of each the builder and utility duties. You possibly can’t rerun the Builder process manually.

IronWork and PaperTrail
Wanting on the logs in IronWork is an actual comfort however you’ll want to use a 3rd get together system to handle your logging. I like PaperTrail and the IronWorker integration is seamless.

Go to PaperTrail and create a free account:

https://papertrailapp.com/

After you get your account and login, go to the Dashboard.

Screen Shot

Discover the Create Group button and create a brand new group:

Screen Shot

Click on the Save button on the backside. Now on the Dashboard it is best to have your new group:

Screen Shot

Go to the Account choices.

Screen Shot

Create a Log Vacation spot on your IronWorker Check venture. Click on on the Create log vacation spot button:

Screen Shot

Click on on the Edit Settings button:

Screen Shot

Be sure to settle for logs from unrecognized methods and choose the group you simply created. Then hit the Replace button.

Now copy the vacation spot url and return to your IronWorker Check venture. Choose the settings icon:

Screen Shot

Take the PaperTrail url and enter it into the Logger URL textual content field utilizing udp because the protocol. Click on the Replace button after which click on on the Employee button once more and discover the buildandrun process. The udp have to be lowercase or your process will fail.

Queue the duty one final time and let it run to completion. As the duty is working, return to the PaperTrail web site. Go to the Dashboard and hit the refresh button on the browser:

Screen Shot

You need to begin seeing occasions coming into your group.  Click on on the All occasions drop down on the appropriate and you will notice the logs in PaperTrail.

Screen Shot

Conclusion
I simply scratched the floor with how you need to use IronWorker to run your functions. It is a actually versatile atmosphere with actually no restrictions. You’ve gotten entry to obtain and set up any packages you want, entry to the native disk and integration to PaperTrail and some different logging methods.

Although you don’t want a Linux VM to make use of IronWorker, chances are you’ll need to take into account having one so you’ll be able to stage and cargo your binary packages straight. Once more, you’ve got the flexibleness to make use of IronWorker as you see match.

I hope you check out the service. Use my utility or construct your personal. Publish a remark about your expertise and something new your study. I plan on utilizing IronWorker for 2 tasks I’m engaged on and count on solely nice issues.



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments