Instead of init.d use systemctl

Not a question but a solution that I wanted to share. I generally run latest version of Fedora (18) on my Linux systems. Yep kind of a bleeding edge person. So, this is for people running stash on linux with systemctl being used rather than init.d. You can very easily setup a service file to run stash, here is how I did it.

My environment is:

Fedora 18 Linux
Stash v2.2.0
jdk 1.7.0-17

Create a stash.service file in /usr/lib/systemd/system/ directory that looks like this (adjust ExecStart and ExecStop with your stash install directory):

Description=Atlassian Stash Service



Then enable the service to start at boot with:

systemctl enable stash.service

Or disable it with

systemctl disable stash.service

Or see if it is set to start at boot with:

if [ -f /etc/systemd/system/*.wants/stash.service ]; then echo "On"; else echo "Off";fi

You now can restart the system and it should start stash as part of the booting process.

To manually start and stop the service you can run:

systemctl start stash
systemctl stop stash

To see the state of stash run:

systemctl status stash

It took me awhile to get use to systemctl over init.d but I do like it now. You can use the old init.d scripts as discribed in stash documentation but I couldn't get it working and just decided to commit to getting it into the systemctl environment

7 answers

1 accepted

1 vote
Accepted answer

Above is the answer...

In the time since this was written the requirements have changed a bit. For Ubuntu 16 I had to add an Environment variable and UMask in order for Bitbucket to load correctly without warnings. I also added a dependency on postgresql.service otherwise I found the database was stopped before Bitbucket (which can't be good). Exchange that for your database of choice.

Note that this script is from an old Stash server setup that has been migrated to Bitbucket server, normally you would not run with the stash username.

Description=Atlassian Bitbucket Server Service postgresql.service



Ah, good point. That's where I put mine, I didn't even notice the OP recommended a different folder.

Thank you, this was very well documented.  The only thing missing for me, adjusting this for a confluence installation, was the User directive.  I added "User=confluence" between the Type and ExecStart directives.

Pretty sure that should be `ExecStop=/opt/atlassian-stash-2.2.0/bin/` right?

Thanks Patrick! I wanted to note that I needed to add postgresql.service to my "Wants=" line as it started up before postgresql did. Perhaps someone else will run into the same issue.

Thank you. I have used this example for my JIRA and Confluence instance on an Arch Linux server. 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted 11 hours ago in United States

Administrators Cleanup

Good morning, After a long weekend cleaning up, I am still in the cleanup mode 😊. I am curious to know: When do you feel the urgency to cleanup your Atlassian Tools? How many times do y...

16 views 0 0
View post

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you