Skip to main content
Known Participant
October 6, 2010
Question

jsx as a windows service

  • October 6, 2010
  • 2 replies
  • 1625 views

I wrote socket listener class in javascript/photoshopscript.

I basically need this to be running at all times.

Here is a dumbed down code example that basically returns what is sent to it.

Is there anyway to get this to run as a windows service?

Currently I start it up from extendscript

#target photoshop

function Server( _port ){

    this.port = _port;

    this.tcp = new Socket( )

    this.connection;

    this.start = function( callBackFunc ){

        if( this.tcp.listen( this.port ) ){

            for(;;){

                this.connection = this.tcp.poll()

                if( this.connection != null ){

                    var tmp = this.connection.readln()

                    callBackFunc( tmp )

                }

            }

        }

    },

    this.response = function( val ){

        this.connection.writeln( val )

    }

}

function callBackFunction( data ){

    server.response( data )

}

var server = new Server( 12345 );

server.start( callBackFunction )

This topic has been closed for replies.

2 replies

Inspiring
October 7, 2010

I also would recommend you to use Bridges app.scheduleTask Function, because Bridge can supervise if Photoshop is currently processing a job and can collect the incoming jobs in a pipeline. The jobs are passed to photoshop one by one. In my implementation, that I am successfully using for 5 years now I have a folder where all the jobfiles come in. Photoshop is configured that it processes all files in this folder and after this just quits. Bridge is running all the time and is also supervising this folder. If new files are added Bridge just starts photoshop. This is a very easy and robust way to do it, because by quitting photoshop after a series of tasks you avoid memory leaks.

Regards, markus

Inspiring
October 7, 2010

"scheduleTask" is what I meant to say; not "addTask" .

One thing you may alsol want to do is have a palette or panel in Bridge show the current queue of jobs being processed. This is nice to have especially when the jobs take several minutes to run.

Inspiring
October 6, 2010
Is there anyway to get this to run as a windows service?

Nope.

I basically need this to be running at all times.

I think you would be better off running this in Bridge and 'addTask' to run it in it's own thread. When you've received a request, pass it on to Photoshop.

jay_2014Author
Known Participant
October 7, 2010

Thanks xbytor2, but I have two questions for you.

1) What is your reasoning behind porting it to bridge?

2)How do I addTask in bridge. Sorry I am just not familiar with bridge at all. Could you point me to some docs that explain it. My google skills failed on this. My searchs turn up with running all scripts from the estk

Inspiring
October 7, 2010
1) What is your reasoning behind porting it to bridge?

You can run your socket code in a background thread (via addTask) which lets you continue to use Bridge since it's not blocked.I'll see if I have any sample code laying around that I can post.

2)How do I addTask in bridge. Sorry I am just not familiar with bridge at all.

The addTask functions are described in the Bridge Scripting Programmers Guide (or whatever it's called). If it's not in a folder in your Bridge app installaton, it sthould be under http://www.adobe.com/devnet.html somewhere.