Running a SubEthaEdit "server"

Posted by map Mon, 03 Apr 2006 10:10:00 GMT

If you'd like to run SubEthaEdit on a server you might be interested in a few tricks we are using to run see://codingmonkeys.de.

First of all, codingmonkeys.de is not hosted on Mac OS X, but BSD. To forward SubEthaEdit traffic to a Mac OS X machine with Internet connection, we use redir. An example setup for redir would be "redir --lport 6942 --caddr <remoteipaddress> --cport 6942 -nredir --syslog"

Secondly we automate the sharing of documents on the server with an AppleScript that is called as a LoginItem. It takes care of opening the documents we'd like to be hosted, setting the access control to read/write and sharing them.

tell application "SubEthaEdit"
    activate
    open ":Users:subethaserver:Documents:SubEthaEdit Documents:Chat.txt"
    open ":Users:subethaserver:Documents:SubEthaEdit Documents:conference.notes"
    open ":Users:subethaserver:Documents:SubEthaEdit Documents:index.html"
    tell documents
        set access control to read write
        set announced to true
    end tell
end tell

If you also would like to auto-save documents on the server e.g. every 5 minutes, you could use another AppleScript:

tell application "SubEthaEdit"
    repeat until false is true
        save documents
        delay 5 * 60
    end repeat
end tell

Posted in  | 17 comments

Comments

  1. David Steinbrunner said about 2 hours later:
    Are there any plans to have an actual server product? I have always thought it would be nice to be able to point SubEthaEdit at a CVS/SVN repository and just have the whole thing served with directory structures and all kept in tact. This would make users find shared documents though nav services rather than than just going through a simple list but I think that the abstraction needed for the server feature would be a great value add for developers working on projects with a great deal of abstraction themselves (which require working with many file at different times in different places in the repository).
  2. map said about 3 hours later:
    I'd prefer not to talk about plans, but we of course have thought about a "real" SubEthaEdit server process.
  3. pmcm said about 6 hours later:
    I think just "repeat" is nicer than: "repeat until false is true" ...just a though.
  4. jonct said about 21 hours later:
    Or simply: on idle, tell application "SubEthaEdit" to save documents, end idle.
  5. johnsonwax said 1 day later:
    Definitely do on idle - much better on CPU load.
  6. Stefan Huy said 4 days later:
    :)
  7. Armin said 7 days later:
    I extended the script a little: on run tell application "Finder" set docFolder to path to documents folder from user domain set seeFolder to folder "SubEthaEdit Server Documents" of docFolder set thelist to every file of seeFolder repeat with x in thelist tell application "SubEthaEdit" open x tell document 1 set access control to read write set announced to true end tell end tell end repeat end tell return idletime end run on idle tell application "SubEthaEdit" save every document end tell return idletime end idle Save as application, be sure to check "Stay Open" and put the script applet in the login items. Then create the folder "SubEthaEdit Server Documents" in your documents folder, put something in there. Share and enjoy!
  8. Armin said 7 days later:
    formatting didn't make it in to the previous comment: apologies
    on run
    	tell application "Finder"
    		set docFolder to path to documents folder from user domain
    		set seeFolder to folder "SubEthaEdit Server Documents" of docFolder
    		set thelist to every file of seeFolder
    		repeat with x in thelist
    			tell application "SubEthaEdit"
    				open x
    				tell document 1
    					set access control to read write
    					set announced to true
    				end tell
    			end tell
    		end repeat
    	end tell
    	
    	return idletime
    end run
    
    on idle
    	tell application "SubEthaEdit"
    		save every document
    	end tell
    	
    	return idletime
    end idle
    Save as application, be sure to check "Stay Open" and put the script applet in the login items.
  9. Dave said 22 days later:
    repeat until false is true Love it!
  10. Chris Bracey said about 1 month later:
    When I use the original Save script, after save every document the Event Log says {missing value, missing value...} (one for every open see document) Sorry, I'm new to AppleScript, so I'm not sure how significant the error is - the changes appear to be saving for at least the first few times. But definitely after the scripts been running for a few hours the saves don't seem to be happening any more. I'm uncomfortable about the processor load with the "Repeat until true equals false" bit, so thought I'd try "on idle" If I say: on idle tell application "SubEthaEdit" save every document end tell end idle nothing seems to happen If I use Armin's script (Thanks, Armin!), the top part works fine (with the addition of telling Finder "set visible of process "SubEthaEdit" to false"), but it chokes on "return idletime" (idletime not defined), and if I take out the "return idletime" lines, it never goes into the on idle part of the script... I would really appreciate if someone could point out what I'm missing here! thanks Chris
  11. dom said about 1 month later:

    You have to replace ideltime with the value in seconds that you want to wait until your handler gets called again. So you would exit the idle with a return 5*60 to have the same effect as the loop above.

    "save documents" returns a list of missing values that is as long as the number of documents. This isn't particularly useful (you could take the length as an indicator on how many documents have been saved) but not a problem either. If "save documents" is the last statement in your script then the Script Editor reports its return value as result of the script. So This isn't an error.

  12. Low Cost Domains said over 4 years later:

    Great blog post. It’s useful information.

  13. fabulous said over 4 years later:

    This is the most comprehensive guide I have come across. Thanks for sharing this with us

  14. fabulous said over 4 years later:

    This is the most comprehensive guide I have come across. Thanks for sharing this with us

  15. Antony said over 4 years later:

    Great guide! I will try it. I hope it is not going to eat my CPU. I have a linux based VPS hosing.

  16. andrew thomas said over 4 years later:

    a good explanation about the warning regarding mixed line endings. It is very much useful in preventing subversion difficulties that arise due to mixed line ending. Though sometime it is quiet annoying but at the same time very informative in building application. Nice work. Thanks. andrewthomas

  17. elina smith said over 4 years later:

    how can i put " created by subethaedit" button on my website?

(leave url/email »)

   Comment Markup Help Preview comment