Arc Forumnew | comments | leaders | submitlogin
1 point by palsecam 5454 days ago | link | parent

> reference to undefined identifier: empty?

Strange, which version of mzscheme do you use (`mzscheme -v')? 'empty? is in the MzScheme base "scheme" module for me (MzScheme 4.2.1)!

Anyway, 'empty? is called only in as.scm, and you can actually leave this file unchanged for your case (I think). Just patch ac.scm.

> Also what does (asv) do instead of (load "news.arc") (nsv)?

'asv is used to start the "Appplication server" defined in "app.arc". App.arc is generic, and news.arc use/require it. I use it in the example to see if maybe it was a problem w/ news.arc specifically (and because I feel lazy about typing "(load ...)": app.arc is in the Arc "stdlib" (see the file "libs.arc"), and so is loaded by default).

'nsv is defined like this, in "news.arc":

   (def nsv ((o port 8080))
     [...]        ; do news-specific init stuff...
     (asv port))  ; relay to 'asv, which itself relays to 'serve (defined in srv.arc)
The "sv" in "asv" / "nsv" is for "serve".

> How are generally other people running it detached?

They don't: Arc is different :-D

---

Ah also, to start the news server in the background, no need of a script, you could use:

  $ echo '(nsv)' | arc news.arc - &
But assuming you use a slightly improved version of the (full) patch this time:

  in as.scm:

  -      (for-each (lambda (f) (aload f)) args)  ; ...execute them!
  +	 (for-each (lambda (f) (if (string=? f "-") (tl) (aload f))) args)
But you still need to leave the terminal opened. To fix that, I don't know you may use some Unix daemon-ization magic. It becomes specific to your needs. Are you trying to use the news.arc forum on a (distant) server?

Once again, consider `screen'. Arc has no Unix signal handling for instance, so an "Arc daemon" would not be "powerful". The only possible interaction would be to kill it (via `kill'). Better keep an eye on it, i.e: keep a REPL opened to manage your forum.

---

Have a look at http://arclanguage.org/formatdoc



2 points by user2 5453 days ago | link

Thanks for the info.

I am using mzscheme 372 as described here: http://arclanguage.org/install

I tried:

  $ echo '(nsv)' | arc news.arc - &
I got repetitively:

  arc> Error: "Bad object in expression #<eof>"
  arc> Error: "Bad object in expression #<eof>"
  ...
I am using a remote vps, hence I would like to start the service and quit the server. To be honest, a web service without daemonizing does not sound very intuitive. When I say I need to stay connected to the server to keep the service alive, forums users say "Ah man, what kind of a computer engineer are you?" ;-) I think something like this must be done: http://www.itp.uzh.ch/~dpotter/howto/daemonize

Do you think if I get the latest version of mzscheme your patch it will work? What about the 15 lines offset hunk? Patch didn't seem to apply perfectly.

-----

2 points by palsecam 5453 days ago | link

Yes, try the latest version of MzScheme. Seeing "bad object in expression #<eof>", I'm not even sure ac.scm is patched correctly.

http://arclanguage.org/install has not been updated, but the big feature of the 3.1 version is that it can runs on recent (> 4.1) MzScheme. See http://arclanguage.org/item?id=10254.

Edit: oh yes, maybe you use Arc 3! The current version is Arc 3.1: see the previous link. Direct download: http://ycombinator.com/arc/arc3.1.tar. The patch is to be used with the 3.1!

> To be honest, a web service without daemonizing does not sound very intuitive. When I say I need to stay connected to the server to keep the service alive, forums users say "Ah man, what kind of a computer engineer are you?"

I agree it's not intuitive, but the use of `screen' + long-lived REPL to manage the forum can actually be seen as quite smart:

  $ screen arc
  arc> (load "news.arc")
  arc> (thread:nsv)   ; start it in a new thread, to not block the REPL
  arc> ^A d  ; CTRL-A d, to detach the `screen'
  [detached]
Your forum is started and your screen session detached. You can safely logout and exit your SSH session at this point.

At any time, you can login back to the server and do:

  $ screen -r   # resume
  arc> ; you're in front of the forum REPL
  arc> requests*  ; ultra basic analytics: show the number of requests served
  161803
  arc> (change-some-settings)  ; you get the idea
And if you need to stop the server and exit Arc:

  arc> (exit)  ; or just ^D if you have applied the patch
  [screen is terminating]
  $ 
One thing that is missing is there is no watchdog, no automatic restart in case of failure (I mean big failure, like: the Arc process died). Sure, it's not as solid as the daemontools (http://cr.yp.to/daemontools.html), but it should suffice. srv.arc has some kind of protection against flood, handler threads that would get mad, etc.

If you really want to just echo '(nsv)' | arc news.arc -, then use version 3.1, the patch and a small shell or Perl wrapper script to daemonize the Arc process. Some fork + redirect standard ports + setsid magic, then exec the Arc process.

In Perl, from `perldoc perlipc':

      use POSIX 'setsid';

      sub daemonize {
          # chdir '/'               or die "Can't chdir to /: $!";
          open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
          open STDOUT, '>/dev/null'
                                  or die "Can't write to /dev/null: $!";
          defined(my $pid = fork) or die "Can't fork: $!";
          exit if $pid;
          setsid                  or die "Can't start a new session: $!";
          open STDERR, '>&STDOUT' or die "Can't dup stdout: $!";
      }
Or play it hardcore and use the daemontools :-P!

-----

1 point by user2 5449 days ago | link

Thanks, I got it working. For reference, particularly your screen trick worked very well over ssh. -L option also helps if screen dies on you, it creates a log file in the current dir that you can check and see what went wrong.

Next, I believe I need to learn a bit of arc to see how I can make changes on the website.

-----

1 point by user2 5453 days ago | link

OK thanks, let me try these.

By the way, somehow I managed to log out and the server still seems to be up. I didn't use screen or anything. I will investigate how it worked.

-----

1 point by akkartik 5453 days ago | link

Sometimes interactive processes will 'go rogue' when you ctrl-c them. Run ps and kill to get rid of it.

-----