Added server auto starting support
git-svn-id: svn://svn.savannah.nongnu.org/lash/trunk@23 1de19dc7-4e3f-0410-a61d-eddf686bf0b7
This commit is contained in:
parent
5b29ded92b
commit
09e155039a
|
@ -317,6 +317,21 @@ To keep track of what is happening with LASH, the user can run the
|
|||
@command{lash_panel} program (though this is not necessary, and it can
|
||||
be started later at any time).
|
||||
|
||||
The environment variable @code{LASH_START_SERVER} can be set to have any
|
||||
LASH client automatically start the server if one isn't already running.
|
||||
Doing this you can simply put @command{lash_panel} (or any other LASH
|
||||
client) in your applications menu and have LASH automatically work without
|
||||
having to remember to start the server manually.
|
||||
|
||||
If you're using a Bourne compatible shell like @command{bash} (if you don't
|
||||
know, you probably are) you can enable auto-start with the following command:
|
||||
|
||||
@command{export LASH_START_SERVER=1}
|
||||
|
||||
If you would like to always have the server started, put that command in the
|
||||
file ~/.bashrc (or in /etc/profile if you are root and want it set system
|
||||
wide) to have it run whenever a new shell is started.
|
||||
|
||||
@subsubsection A client connection
|
||||
|
||||
The user then starts a JACK client program. It opens a connection
|
||||
|
|
|
@ -129,6 +129,8 @@ lash_init(lash_args_t * args,
|
|||
char *str;
|
||||
const char *cstr;
|
||||
char wd[MAXPATHLEN];
|
||||
int tries;
|
||||
uuid_t id;
|
||||
|
||||
client = lash_client_new();
|
||||
connect_params = lash_connect_params_new();
|
||||
|
@ -167,11 +169,51 @@ lash_init(lash_args_t * args,
|
|||
err = lash_comm_connect_to_server(client,
|
||||
cstr ? cstr : "localhost",
|
||||
"lash", connect_params);
|
||||
|
||||
/* couldn't connect, try to start a new server */
|
||||
/* but not if this client has been started by a server, in which
|
||||
case something must be broken if we can't connect */
|
||||
lash_args_get_id(args, id);
|
||||
if (err && getenv("LASH_START_SERVER") != NULL && uuid_is_null(id)) {
|
||||
fprintf(stderr, "%s: trying to start new LASH server\n",
|
||||
__FUNCTION__);
|
||||
err = fork();
|
||||
if (err == 0) {
|
||||
daemon(0, 0);
|
||||
execlp("lashd", "lashd", NULL);
|
||||
_exit(-1);
|
||||
}
|
||||
|
||||
/* if the fork succeeded, try to connect to the new server */
|
||||
else if (err > 0) {
|
||||
for (tries = 0; tries < 5; ++tries) {
|
||||
sleep(1);
|
||||
err = lash_comm_connect_to_server(client,
|
||||
cstr ? cstr : "localhost",
|
||||
"lash", connect_params);
|
||||
if (err == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* fork failed */
|
||||
else {
|
||||
fprintf(stderr, "%s: fork failed while starting new server: %s\n",
|
||||
__FUNCTION__, strerror(err));
|
||||
}
|
||||
}
|
||||
|
||||
lash_connect_params_destroy(connect_params);
|
||||
if (err) {
|
||||
fprintf(stderr,
|
||||
"%s: could not connect to server '%s' - disabling lash\n",
|
||||
"%s: could not connect to server '%s' - disabling LASH\n",
|
||||
__FUNCTION__, cstr ? cstr : "localhost");
|
||||
|
||||
if (getenv("LAST_START_SERVER") == NULL)
|
||||
fprintf(stderr, "%s: set the environment variable LASH_START_SERVER "
|
||||
"to have the LASH \n%s: server started automatically\n",
|
||||
__FUNCTION__, __FUNCTION__);
|
||||
|
||||
lash_client_destroy(client);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -183,7 +225,7 @@ lash_init(lash_args_t * args,
|
|||
client);
|
||||
if (err) {
|
||||
fprintf(stderr,
|
||||
"%s: error creating recieve thread - disabling lash: %s\n",
|
||||
"%s: error creating recieve thread - disabling LASH: %s\n",
|
||||
__FUNCTION__, strerror(err));
|
||||
|
||||
lash_client_destroy(client);
|
||||
|
@ -195,7 +237,7 @@ lash_init(lash_args_t * args,
|
|||
client);
|
||||
if (err) {
|
||||
fprintf(stderr,
|
||||
"%s: error creating send thread - disabling lash: %s\n",
|
||||
"%s: error creating send thread - disabling LASH: %s\n",
|
||||
__FUNCTION__, strerror(err));
|
||||
|
||||
client->recv_close = 1;
|
||||
|
|
Loading…
Reference in New Issue