Web app on Mac personal web sharing

This is a general Unix restriction not unique to Apple
Linux has the same restriction for non root users

[quote=89217:@Norman Palardy]This is a general Unix restriction not unique to Apple
Linux has the same restriction for non root users[/quote]
Goh, and i thought i finally found a unique positive point to get a Mac.
Norman, you are messsing with my party! . :smiley:

[quote=89030:@Michel Bujardet]…
Now, I still have a question : is it possible to access a standalone app without explicitly enter the port number ?[/quote]
Usually I do what Brad already suggested: using an iframe.

Another thing one can do is to create an index.php file which redirects to the desired page/port, for instance like this:

[code]<?php
$myurl=$_SERVER[‘HTTP_HOST’];

switch ($myurl)
{
case “www.example.com”:
header(“Location: http://www.example.com:8080”);
break;
case “example.com”:
header(“Location: http://www.example.com:8080”);
break;
default:
// echo $_SERVER[“HTTP_REFERER”];
header(“Location: http://www.example.com:8080”);
}
?>[/code]

You may find other ways to redirect as well, using javascript etc.

Another way to redirect:

[code]

Page Redirection If you are not redirected automatically, follow the link to example [/code]

Einen hab’ ich noch:

[code]Place the following HTML redirect code between the and tags of your HTML code.

The above HTML redirect code will redirect your visitors to another web page instantly. The content="0; may be changed to the number of seconds you want the browser to wait before redirecting.[/code]

I understand. Seems daemonizing an app on Mac is nightmarish anyways.

Thank you Oliver for all these methods :slight_smile:

I just found a very simple solution to launch a standalone app : use a bash script. When launched by a bash script, the program continues to ru after the terminal has been closed.

And the bash script can be added to the startup programs :slight_smile:

[quote=89218:@Andre Kuiper]Goh, and i thought i finally found a unique positive point to get a Mac.
Norman, you are messsing with my party! . :D[/quote]
From my experience - get one - throw away extra laptops & machines for Windows & Linux and just run VM’s for those as you can back up & restore a VM a lot faster than backing up & restoring Linux or Windows :stuck_out_tongue:
I used to have 10 machines and now I’m down to 2 with a few TB of VM’s.
I like actually NOT heating my office via CPU heat sinks & fans :stuck_out_tongue:

[quote=89243:@Michel Bujardet]I understand. Seems daemonizing an app on Mac is nightmarish anyways.
[/quote]
Set it up as a launchD item which takes as short or long time as you want.
The system then can start it at system startup, relaunch it automatically if it fails, and all kinds of other things.

[quote=89302:@Michel Bujardet]I just found a very simple solution to launch a standalone app : use a bash script. When launched by a bash script, the program continues to ru after the terminal has been closed.

And the bash script can be added to the startup programs :)[/quote]

Use Launchd - its “the right way” really

Tried that. Inconclusive.

I have created a wl.plist by modifying a very simple plist :

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC -//Match Software//DTD PLIST 1.0//EN http://www.match-software.com/DTDs/PropertyList-1.0.dtd > <plist version="1.0"> <dict> <key>Label</key> <string>com.michelbujardet.weblistbox</string> <key>ProgramArguments</key> <array> <string>/Users/Mitch/Desktop/boo/weblistbox --port=8080 --maxsockets=100 &</string> </array> <key>KeepAlive</key> <true></true> </dict> </plist>

chmod 644

Now I try to load it :

sudo launchctl load /Users/Mitch/Desktop/boo/wl.plist or launchctl load /Users/Mitch/Desktop/boo/wl.plist

result :

launchctl: no plist was returned for: /Users/Mitch/Desktop/boo/wl.plist launchctl: no plist was returned for: /Users/Mitch/Desktop/boo/wl.plist nothing found to load

Went through all I could find on the Internet for a hint about what is going on – no luck.

In general, I will try to play things by the book. But the “right way” does not work right :confused:

When the book is not working as expected, what works works. I call that being pragmatic.

After all, a bash script is just as fine as a command typed by a human in a terminal window. What could be wrong there ?

If I may suggest Lingon, it makes it easy to create launchd scripts that just work.

It also takes care of the locations for the launchagents/launchdaemons, as the plists can’t be anywhere on the disk but under Library/LaunchAgents or Library/LaunchDaemons

I use this Lingon, which is free: http://sourceforge.net/projects/lingon/

I haven’t tested these Lingons, which aren’t: http://www.peterborgapps.com/lingon/

A shell script doesn’t work any better than running the thing yourself just by itself. If you’re launching from within the script then either you’re daemonizing it (like executing with & at the end) or offloading the startup to something else (without seeing the shell script it’s hard to be clear).

Being on mac, you have a half-dozen ways to startup programs, though. You could also drop it in the startupitems folder in either your library, the root one or System’s one, use the login items in your preferences, create a launchd startup script, etc. Even the old login scripts still work (linked for completists, but really advised against)

Plists themselves must be placed in explicit directories or they won’t even be loaded:

Run as root:
/Library/LaunchDaemons
/System/Library/LaunchDaemons (should be used by Apple alone)

Run as the user when a user logs on:
/Library/LaunchAgents
/System/Library/LaunchAgents (should be used by Apple alone)

Run as the user, when the user logs on:
~/Library/LaunchAgents

Putting valid plists in those directories, unless they have the “disabled” flag, will start them upon startup/login.

If the “disabled” flag is set then they need to be loaded and started explicitly.

launchctl load path/to/plist
launchctl start jobname (as defined in plist)

To disable App Nap for all applications:

type in Terminal

defaults write NSGlobalDomain NSAppSleepDisabled -bool YES

[quote=89454:@Eduardo Gutierrez de Oliveira]Eduardo Gutierrez de Oliveira 1 hour ago Alpha Testers, Beta Testers Europe (Madrid, Spain)
If I may suggest Lingon, it makes it easy to create launchd scripts that just work.

It also takes care of the locations for the launchagents/launchdaemons, as the plists can’t be anywhere on the disk but under Library/LaunchAgents or Library/LaunchDaemons

[/quote]

Thank you Eduardo. This is far clearer than anything I found by googling Launchd :slight_smile: I am sure this will greatly help.

I know how unintuitive it can be at the beginning. I had to tacke a lot of this when setting up the launchd jobs for SMBUp. Especially since samba demands to be run as root but launchctl doesn’t just accept authorization shells.

Launchctl is pretty powerful for a lot of things. You can set up a launchctl that runs a program when a directory or a file changes, for example.